Skip to content

Commit

Permalink
Moved the IssuesController routing tests to an integration test.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3474 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Feb 22, 2010
1 parent 0341ac8 commit 89cf2d2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 116 deletions.
115 changes: 0 additions & 115 deletions test/functional/issues_controller_test.rb
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 => ''
Expand Down Expand Up @@ -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
Expand Down
44 changes: 43 additions & 1 deletion test/integration/routing_test.rb
Expand Up @@ -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

0 comments on commit 89cf2d2

Please sign in to comment.