From 89cf2d256dd4a2072b223f7d8117cb4997ae86d8 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 22 Feb 2010 18:15:07 +0000 Subject: [PATCH] Moved the IssuesController routing tests to an integration test. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3474 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/issues_controller_test.rb | 115 ---------------------- test/integration/routing_test.rb | 44 ++++++++- 2 files changed, 43 insertions(+), 116 deletions(-) diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 604ab66f5da..83a2824fba2 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -53,13 +53,6 @@ def setup User.current = nil end - def test_index_routing - assert_routing( - {:method => :get, :path => '/issues'}, - :controller => 'issues', :action => 'index' - ) - end - def test_index Setting.default_language = 'en' @@ -88,13 +81,6 @@ def test_index_should_not_list_issues_when_module_disabled assert_tag :tag => 'a', :content => /Subproject issue/ end - def test_index_with_project_routing - assert_routing( - {:method => :get, :path => '/projects/23/issues'}, - :controller => 'issues', :action => 'index', :project_id => '23' - ) - end - def test_index_should_not_list_issues_when_module_disabled EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1") get :index @@ -105,13 +91,6 @@ def test_index_should_not_list_issues_when_module_disabled assert_no_tag :tag => 'a', :content => /Can't print recipes/ assert_tag :tag => 'a', :content => /Subproject issue/ end - - def test_index_with_project_routing - assert_routing( - {:method => :get, :path => 'projects/23/issues'}, - :controller => 'issues', :action => 'index', :project_id => '23' - ) - end def test_index_with_project Setting.display_subprojects_issues = 0 @@ -146,17 +125,6 @@ def test_index_with_project_and_subprojects_should_show_private_subprojects assert_tag :tag => 'a', :content => /Issue of a private subproject/ end - def test_index_with_project_routing_formatted - assert_routing( - {:method => :get, :path => 'projects/23/issues.pdf'}, - :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' - ) - assert_routing( - {:method => :get, :path => 'projects/23/issues.atom'}, - :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' - ) - end - def test_index_with_project_and_filter get :index, :project_id => 1, :set_filter => 1 assert_response :success @@ -208,17 +176,6 @@ def test_index_csv_with_project assert_equal 'text/csv', @response.content_type end - def test_index_formatted - assert_routing( - {:method => :get, :path => 'issues.pdf'}, - :controller => 'issues', :action => 'index', :format => 'pdf' - ) - assert_routing( - {:method => :get, :path => 'issues.atom'}, - :controller => 'issues', :action => 'index', :format => 'atom' - ) - end - def test_index_pdf get :index, :format => 'pdf' assert_response :success @@ -347,24 +304,6 @@ def test_changes assert_equal 'application/atom+xml', @response.content_type end - def test_show_routing - assert_routing( - {:method => :get, :path => '/issues/64'}, - :controller => 'issues', :action => 'show', :id => '64' - ) - end - - def test_show_routing_formatted - assert_routing( - {:method => :get, :path => '/issues/2332.pdf'}, - :controller => 'issues', :action => 'show', :id => '2332', :format => 'pdf' - ) - assert_routing( - {:method => :get, :path => '/issues/23123.atom'}, - :controller => 'issues', :action => 'show', :id => '23123', :format => 'atom' - ) - end - def test_show_by_anonymous get :show, :id => 1 assert_response :success @@ -439,17 +378,6 @@ def test_show_atom assert @response.body.include?("<img src=\"http://test.host/attachments/download/10\" alt=\"\" />"), "Body did not match. Body: #{@response.body}" end - def test_new_routing - assert_routing( - {:method => :get, :path => '/projects/1/issues/new'}, - :controller => 'issues', :action => 'new', :project_id => '1' - ) - assert_recognizes( - {:controller => 'issues', :action => 'new', :project_id => '1'}, - {:method => :post, :path => '/projects/1/issues'} - ) - end - def test_show_export_to_pdf get :show, :id => 3, :format => 'pdf' assert_response :success @@ -656,13 +584,6 @@ def test_post_new_should_ignore_non_safe_attributes end end - def test_copy_routing - assert_routing( - {:method => :get, :path => '/projects/world_domination/issues/567/copy'}, - :controller => 'issues', :action => 'new', :project_id => 'world_domination', :copy_from => '567' - ) - end - def test_copy_issue @request.session[:user_id] = 2 get :new, :project_id => 1, :copy_from => 1 @@ -672,17 +593,6 @@ def test_copy_issue assert_equal orig.subject, assigns(:issue).subject end - def test_edit_routing - assert_routing( - {:method => :get, :path => '/issues/1/edit'}, - :controller => 'issues', :action => 'edit', :id => '1' - ) - assert_recognizes( #TODO: use a PUT on the issue URI isntead, need to adjust form - {:controller => 'issues', :action => 'edit', :id => '1'}, - {:method => :post, :path => '/issues/1/edit'} - ) - end - def test_get_edit @request.session[:user_id] = 2 get :edit, :id => 1 @@ -733,13 +643,6 @@ def test_update_edit_form assert_equal 'This is the test_new issue', issue.subject end - def test_reply_routing - assert_routing( - {:method => :post, :path => '/issues/1/quoted'}, - :controller => 'issues', :action => 'reply', :id => '1' - ) - end - def test_reply_to_issue @request.session[:user_id] = 2 get :reply, :id => 1 @@ -1107,17 +1010,6 @@ def test_post_bulk_edit_should_not_redirect_back_using_the_back_url_parameter_of assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier end - def test_move_routing - assert_routing( - {:method => :get, :path => '/issues/1/move'}, - :controller => 'issues', :action => 'move', :id => '1' - ) - assert_recognizes( - {:controller => 'issues', :action => 'move', :id => '1'}, - {:method => :post, :path => '/issues/1/move'} - ) - end - def test_move_one_issue_to_another_project @request.session[:user_id] = 2 post :move, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' @@ -1286,13 +1178,6 @@ def test_context_menu_multiple_issues_of_different_project :class => 'icon-del disabled' } end - def test_destroy_routing - assert_recognizes( #TODO: use DELETE on issue URI (need to change forms) - {:controller => 'issues', :action => 'destroy', :id => '1'}, - {:method => :post, :path => '/issues/1/destroy'} - ) - end - def test_destroy_issue_with_no_time_entries assert_nil TimeEntry.find_by_issue_id(2) @request.session[:user_id] = 2 diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 5f9b8c19289..0e347d77dc1 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -18,9 +18,51 @@ require "test_helper" class RoutingTest < ActionController::IntegrationTest + context "issues" do + # REST actions + should_route :get, "/issues", :controller => 'issues', :action => 'index' + should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf' + should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom' + should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml' + should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23' + should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' + should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' + should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml' + should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64' + should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf' + should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom' + should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml' + + should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23' + + should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' + # TODO: Should use PUT + should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' + + # TODO: Should use DELETE + should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64' + + # Extra actions + should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64' + + should_route :get, "/issues/1/move", :controller => 'issues', :action => 'move', :id => '1' + should_route :post, "/issues/1/move", :controller => 'issues', :action => 'move', :id => '1' + + should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1' + + should_route :get, "/issues/calendar", :controller => 'issues', :action => 'calendar' + should_route :post, "/issues/calendar", :controller => 'issues', :action => 'calendar' + should_route :get, "/projects/project-name/issues/calendar", :controller => 'issues', :action => 'calendar', :project_id => 'project-name' + should_route :post, "/projects/project-name/issues/calendar", :controller => 'issues', :action => 'calendar', :project_id => 'project-name' + + should_route :get, "/issues/gantt", :controller => 'issues', :action => 'gantt' + should_route :post, "/issues/gantt", :controller => 'issues', :action => 'gantt' + should_route :get, "/projects/project-name/issues/gantt", :controller => 'issues', :action => 'gantt', :project_id => 'project-name' + should_route :post, "/projects/project-name/issues/gantt", :controller => 'issues', :action => 'gantt', :project_id => 'project-name' + end + context "issue reports" do should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567' should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to' end - end