summaryrefslogtreecommitdiffstats
path: root/test/functional/issues_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/issues_controller_test.rb')
-rw-r--r--test/functional/issues_controller_test.rb168
1 files changed, 147 insertions, 21 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index daca0eb41..1097ca5d1 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -49,6 +49,13 @@ class IssuesControllerTest < Test::Unit::TestCase
@response = ActionController::TestResponse.new
User.current = nil
end
+
+ def test_index_routing
+ assert_routing(
+ {:method => :get, :path => '/issues'},
+ :controller => 'issues', :action => 'index'
+ )
+ end
def test_index
get :index
@@ -74,6 +81,31 @@ class IssuesControllerTest < Test::Unit::TestCase
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
+ assert_response :success
+ assert_template 'index.rhtml'
+ assert_not_nil assigns(:issues)
+ assert_nil assigns(:project)
+ 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
get :index, :project_id => 1
@@ -107,6 +139,17 @@ class IssuesControllerTest < Test::Unit::TestCase
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
@@ -126,6 +169,17 @@ class IssuesControllerTest < Test::Unit::TestCase
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
@@ -221,6 +275,24 @@ class IssuesControllerTest < Test::Unit::TestCase
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
@@ -251,6 +323,17 @@ class IssuesControllerTest < Test::Unit::TestCase
:child => { :tag => 'legend',
:content => /Notes/ } }
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'
@@ -290,7 +373,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:priority_id => 5}
assert_response :success
assert_template 'new'
- end
+ end
def test_post_new
@request.session[:user_id] = 2
@@ -301,7 +384,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:priority_id => 5,
:estimated_hours => '',
:custom_field_values => {'2' => 'Value for field 2'}}
- assert_redirected_to :controller => 'issues', :action => 'show'
+ assert_redirected_to :action => 'show'
issue = Issue.find_by_subject('This is the test_new issue')
assert_not_nil issue
@@ -330,9 +413,9 @@ class IssuesControllerTest < Test::Unit::TestCase
:subject => 'This is the test_new issue',
:description => 'This is the description',
:priority_id => 5}
- assert_redirected_to :controller => 'issues', :action => 'show'
+ assert_redirected_to :action => 'show'
end
-
+
def test_post_new_with_required_custom_field_and_without_custom_fields_param
field = IssueCustomField.find_by_name('Database')
field.update_attribute(:is_required, true)
@@ -402,6 +485,13 @@ class IssuesControllerTest < Test::Unit::TestCase
:value => 'Value for field 2'}
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
@@ -411,6 +501,17 @@ class IssuesControllerTest < Test::Unit::TestCase
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
@@ -442,6 +543,13 @@ class IssuesControllerTest < Test::Unit::TestCase
:attributes => { :selected => 'selected' } }
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
@@ -473,7 +581,7 @@ class IssuesControllerTest < Test::Unit::TestCase
}
end
end
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal new_subject, issue.subject
# Make sure custom fields were not cleared
@@ -499,7 +607,7 @@ class IssuesControllerTest < Test::Unit::TestCase
}
end
end
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal 'New custom value', issue.custom_value_for(2).value
@@ -519,7 +627,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:notes => 'Assigned to dlopper',
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
end
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal 2, issue.status_id
j = issue.journals.find(:first, :order => 'id DESC')
@@ -536,7 +644,7 @@ class IssuesControllerTest < Test::Unit::TestCase
post :edit,
:id => 1,
:notes => notes
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
assert_equal notes, j.notes
assert_equal 0, j.details.size
@@ -555,7 +663,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:notes => '2.5 hours added',
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
end
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
issue = Issue.find(1)
@@ -581,7 +689,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:id => 1,
:notes => '',
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
assert j.notes.blank?
assert_equal 1, j.details.size
@@ -600,7 +708,7 @@ class IssuesControllerTest < Test::Unit::TestCase
post :edit,
:id => 1,
:notes => ''
- assert_redirected_to 'issues/show/1'
+ assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert issue.journals.empty?
@@ -671,17 +779,28 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_nil Issue.find(2).assigned_to
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] = 1
post :move, :id => 1, :new_project_id => 2
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).project_id
end
def test_bulk_move_to_another_project
@request.session[:user_id] = 1
post :move, :ids => [1, 2], :new_project_id => 2
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
# Issues moved to project 2
assert_equal 2, Issue.find(1).project_id
assert_equal 2, Issue.find(2).project_id
@@ -693,7 +812,7 @@ class IssuesControllerTest < Test::Unit::TestCase
def test_bulk_move_to_another_tracker
@request.session[:user_id] = 1
post :move, :ids => [1, 2], :new_tracker_id => 2
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).tracker_id
assert_equal 2, Issue.find(2).tracker_id
end
@@ -714,10 +833,10 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_response :success
assert_template 'context_menu'
assert_tag :tag => 'a', :content => 'Edit',
- :attributes => { :href => '/issues/edit/1',
+ :attributes => { :href => '/issues/1/edit',
:class => 'icon-edit' }
assert_tag :tag => 'a', :content => 'Closed',
- :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
+ :attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
:class => '' }
assert_tag :tag => 'a', :content => 'Immediate',
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
@@ -726,7 +845,7 @@ class IssuesControllerTest < Test::Unit::TestCase
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
:class => '' }
assert_tag :tag => 'a', :content => 'Copy',
- :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
+ :attributes => { :href => '/projects/ecookbook/issues/1/copy',
:class => 'icon-copy' }
assert_tag :tag => 'a', :content => 'Move',
:attributes => { :href => '/issues/move?ids%5B%5D=1',
@@ -777,11 +896,18 @@ class IssuesControllerTest < Test::Unit::TestCase
: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
post :destroy, :id => 2
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil Issue.find_by_id(2)
end
@@ -797,7 +923,7 @@ class IssuesControllerTest < Test::Unit::TestCase
def test_destroy_issues_and_destroy_time_entries
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'destroy'
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find_by_id([1, 2])
end
@@ -805,7 +931,7 @@ class IssuesControllerTest < Test::Unit::TestCase
def test_destroy_issues_and_assign_time_entries_to_project
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'nullify'
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find(1).issue_id
assert_nil TimeEntry.find(2).issue_id
@@ -814,7 +940,7 @@ class IssuesControllerTest < Test::Unit::TestCase
def test_destroy_issues_and_reassign_time_entries_to_another_issue
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
- assert_redirected_to 'projects/ecookbook/issues'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_equal 2, TimeEntry.find(1).issue_id
assert_equal 2, TimeEntry.find(2).issue_id