diff options
Diffstat (limited to 'test/functional/news_controller_test.rb')
-rw-r--r-- | test/functional/news_controller_test.rb | 99 |
1 files changed, 76 insertions, 23 deletions
diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 6ef39317a..8cb9d86bb 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -33,18 +33,24 @@ class NewsControllerTest < Redmine::ControllerTest end def test_index_with_project - get :index, :project_id => 1 + get :index, :params => { + :project_id => 1 + } assert_response :success assert_select 'h3 a', :text => 'eCookbook first release !' end def test_index_with_invalid_project_should_respond_with_404 - get :index, :project_id => 999 + get :index, :params => { + :project_id => 999 + } assert_response 404 end def test_show - get :show, :id => 1 + get :show, :params => { + :id => 1 + } assert_response :success assert_select 'h2', :text => 'eCookbook first release !' end @@ -54,7 +60,9 @@ class NewsControllerTest < Redmine::ControllerTest attachment.container = News.find(1) attachment.save! - get :show, :id => 1 + get :show, :params => { + :id => 1 + } assert_response :success assert_select 'a', :text => attachment.filename end @@ -65,7 +73,9 @@ class NewsControllerTest < Redmine::ControllerTest user.pref.save! @request.session[:user_id] = 1 - get :show, :id => 1 + get :show, :params => { + :id => 1 + } assert_response :success comments = css_select('#comments .wiki').map(&:text).map(&:strip) @@ -73,13 +83,17 @@ class NewsControllerTest < Redmine::ControllerTest end def test_show_not_found - get :show, :id => 999 + get :show, :params => { + :id => 999 + } assert_response 404 end def test_get_new @request.session[:user_id] = 2 - get :new, :project_id => 1 + get :new, :params => { + :project_id => 1 + } assert_response :success assert_select 'input[name=?]', 'news[title]' end @@ -89,9 +103,14 @@ class NewsControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 with_settings :notified_events => %w(news_added) do - post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', - :description => 'This is the description', - :summary => '' } + post :create, :params => { + :project_id => 1, + :news => { + :title => 'NewsControllerTest', + :description => 'This is the description', + :summary => '' + } + } end assert_redirected_to '/projects/ecookbook/news' @@ -108,9 +127,17 @@ class NewsControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 assert_difference 'News.count' do assert_difference 'Attachment.count' do - post :create, :project_id => 1, - :news => { :title => 'Test', :description => 'This is the description' }, - :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} + post :create, :params => { + :project_id => 1, + :news => { + :title => 'Test', + :description => 'This is the description' + }, + :attachments => { + '1' => { + 'file' => uploaded_test_file('testfile.txt', 'text/plain')} + } + } end end attachment = Attachment.order('id DESC').first @@ -120,23 +147,35 @@ class NewsControllerTest < Redmine::ControllerTest def test_post_create_with_validation_failure @request.session[:user_id] = 2 - post :create, :project_id => 1, :news => { :title => '', - :description => 'This is the description', - :summary => '' } + post :create, :params => { + :project_id => 1, + :news => { + :title => '', + :description => 'This is the description', + :summary => '' + } + } assert_response :success assert_select_error /title cannot be blank/i end def test_get_edit @request.session[:user_id] = 2 - get :edit, :id => 1 + get :edit, :params => { + :id => 1 + } assert_response :success assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !' end def test_put_update @request.session[:user_id] = 2 - put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } + put :update, :params => { + :id => 1, + :news => { + :description => 'Description changed by test_post_edit' + } + } assert_redirected_to '/news/1' news = News.find(1) assert_equal 'Description changed by test_post_edit', news.description @@ -147,9 +186,16 @@ class NewsControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 assert_no_difference 'News.count' do assert_difference 'Attachment.count' do - put :update, :id => 1, - :news => { :description => 'This is the description' }, - :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} + put :update, :params => { + :id => 1, + :news => { + :description => 'This is the description' + }, + :attachments => { + '1' => { + 'file' => uploaded_test_file('testfile.txt', 'text/plain')} + } + } end end attachment = Attachment.order('id DESC').first @@ -158,14 +204,21 @@ class NewsControllerTest < Redmine::ControllerTest def test_update_with_failure @request.session[:user_id] = 2 - put :update, :id => 1, :news => { :description => '' } + put :update, :params => { + :id => 1, + :news => { + :description => '' + } + } assert_response :success assert_select_error /description cannot be blank/i end def test_destroy @request.session[:user_id] = 2 - delete :destroy, :id => 1 + delete :destroy, :params => { + :id => 1 + } assert_redirected_to '/projects/ecookbook/news' assert_nil News.find_by_id(1) end |