diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-11 14:42:10 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-11 14:42:10 +0000 |
commit | ff43bb1a74a7450dbcee2d8b0b152d2173a810e1 (patch) | |
tree | d0af815e4139ee61d415704b72461d131862e619 /test | |
parent | e43f9fc21edc0a7b3451f64204c3399eab359529 (diff) | |
download | redmine-ff43bb1a74a7450dbcee2d8b0b152d2173a810e1.tar.gz redmine-ff43bb1a74a7450dbcee2d8b0b152d2173a810e1.zip |
Refactor: Extract a new IssueMovesController from IssuesController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3936 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/issue_moves_controller_test.rb | 99 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 97 | ||||
-rw-r--r-- | test/integration/routing_test.rb | 4 | ||||
-rw-r--r-- | test/unit/helpers/issue_moves_helper_test.rb | 4 |
4 files changed, 109 insertions, 95 deletions
diff --git a/test/functional/issue_moves_controller_test.rb b/test/functional/issue_moves_controller_test.rb new file mode 100644 index 000000000..083959c74 --- /dev/null +++ b/test/functional/issue_moves_controller_test.rb @@ -0,0 +1,99 @@ +require 'test_helper' + +class IssueMovesControllerTest < ActionController::TestCase + fixtures :all + + def setup + User.current = nil + end + + def test_create_one_issue_to_another_project + @request.session[:user_id] = 2 + post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' + assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_equal 2, Issue.find(1).project_id + end + + def test_create_one_issue_to_another_project_should_follow_when_needed + @request.session[:user_id] = 2 + post :create, :id => 1, :new_project_id => 2, :follow => '1' + assert_redirected_to '/issues/1' + end + + def test_bulk_create_to_another_project + @request.session[:user_id] = 2 + post :create, :ids => [1, 2], :new_project_id => 2 + assert_redirected_to :controller => 'issues', :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 + # No tracker change + assert_equal 1, Issue.find(1).tracker_id + assert_equal 2, Issue.find(2).tracker_id + end + + def test_bulk_create_to_another_tracker + @request.session[:user_id] = 2 + post :create, :ids => [1, 2], :new_tracker_id => 2 + assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' + assert_equal 2, Issue.find(1).tracker_id + assert_equal 2, Issue.find(2).tracker_id + end + + def test_bulk_copy_to_another_project + @request.session[:user_id] = 2 + assert_difference 'Issue.count', 2 do + assert_no_difference 'Project.find(1).issues.count' do + post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'} + end + end + assert_redirected_to 'projects/ecookbook/issues' + end + + context "#create via bulk copy" do + should "allow not changing the issue's attributes" do + @request.session[:user_id] = 2 + issue_before_move = Issue.find(1) + assert_difference 'Issue.count', 1 do + assert_no_difference 'Project.find(1).issues.count' do + post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' + end + end + issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2}) + assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id + assert_equal issue_before_move.status_id, issue_after_move.status_id + assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id + end + + should "allow changing the issue's attributes" do + # Fixes random test failure with Mysql + # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results + Issue.delete_all("project_id=2") + + @request.session[:user_id] = 2 + assert_difference 'Issue.count', 2 do + assert_no_difference 'Project.find(1).issues.count' do + post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' + end + end + + copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) + assert_equal 2, copied_issues.size + copied_issues.each do |issue| + assert_equal 2, issue.project_id, "Project is incorrect" + assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" + assert_equal 3, issue.status_id, "Status is incorrect" + assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" + assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" + end + end + end + + def test_copy_to_another_project_should_follow_when_needed + @request.session[:user_id] = 2 + post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' + issue = Issue.first(:order => 'id DESC') + assert_redirected_to :controller => 'issues', :action => 'show', :id => issue + end + +end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 92e6fd30a..6b23a6511 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1037,95 +1037,6 @@ class IssuesControllerTest < ActionController::TestCase assert_response :redirect assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier end - - def test_perform_move_one_issue_to_another_project - @request.session[:user_id] = 2 - post :perform_move, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' - assert_redirected_to :action => 'index', :project_id => 'ecookbook' - assert_equal 2, Issue.find(1).project_id - end - - def test_perform_move_one_issue_to_another_project_should_follow_when_needed - @request.session[:user_id] = 2 - post :perform_move, :id => 1, :new_project_id => 2, :follow => '1' - assert_redirected_to '/issues/1' - end - - def test_bulk_perform_move_to_another_project - @request.session[:user_id] = 2 - post :perform_move, :ids => [1, 2], :new_project_id => 2 - 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 - # No tracker change - assert_equal 1, Issue.find(1).tracker_id - assert_equal 2, Issue.find(2).tracker_id - end - - def test_bulk_perform_move_to_another_tracker - @request.session[:user_id] = 2 - post :perform_move, :ids => [1, 2], :new_tracker_id => 2 - 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 - - def test_bulk_copy_to_another_project - @request.session[:user_id] = 2 - assert_difference 'Issue.count', 2 do - assert_no_difference 'Project.find(1).issues.count' do - post :perform_move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'} - end - end - assert_redirected_to 'projects/ecookbook/issues' - end - - context "#perform_move via bulk copy" do - should "allow not changing the issue's attributes" do - @request.session[:user_id] = 2 - issue_before_move = Issue.find(1) - assert_difference 'Issue.count', 1 do - assert_no_difference 'Project.find(1).issues.count' do - post :perform_move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' - end - end - issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2}) - assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id - assert_equal issue_before_move.status_id, issue_after_move.status_id - assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id - end - - should "allow changing the issue's attributes" do - # Fixes random test failure with Mysql - # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results - Issue.delete_all("project_id=2") - - @request.session[:user_id] = 2 - assert_difference 'Issue.count', 2 do - assert_no_difference 'Project.find(1).issues.count' do - post :perform_move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' - end - end - - copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) - assert_equal 2, copied_issues.size - copied_issues.each do |issue| - assert_equal 2, issue.project_id, "Project is incorrect" - assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" - assert_equal 3, issue.status_id, "Status is incorrect" - assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" - assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" - end - end - end - - def test_copy_to_another_project_should_follow_when_needed - @request.session[:user_id] = 2 - post :perform_move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' - issue = Issue.first(:order => 'id DESC') - assert_redirected_to :controller => 'issues', :action => 'show', :id => issue - end def test_context_menu_one_issue @request.session[:user_id] = 2 @@ -1156,10 +1067,10 @@ class IssuesControllerTest < ActionController::TestCase :attributes => { :href => '/projects/ecookbook/issues/1/copy', :class => 'icon-duplicate' } assert_tag :tag => 'a', :content => 'Copy', - :attributes => { :href => '/issues/move?copy_options%5Bcopy%5D=t&ids%5B%5D=1', + :attributes => { :href => '/issues/move/new?copy_options%5Bcopy%5D=t&ids%5B%5D=1', :class => 'icon-copy' } assert_tag :tag => 'a', :content => 'Move', - :attributes => { :href => '/issues/move?ids%5B%5D=1', + :attributes => { :href => '/issues/move/new?ids%5B%5D=1', :class => 'icon-move' } assert_tag :tag => 'a', :content => 'Delete', :attributes => { :href => '/issues/destroy?ids%5B%5D=1', @@ -1190,10 +1101,10 @@ class IssuesControllerTest < ActionController::TestCase :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=3', :class => '' } assert_tag :tag => 'a', :content => 'Copy', - :attributes => { :href => '/issues/move?copy_options%5Bcopy%5D=t&ids%5B%5D=1&ids%5B%5D=2', + :attributes => { :href => '/issues/move/new?copy_options%5Bcopy%5D=t&ids%5B%5D=1&ids%5B%5D=2', :class => 'icon-copy' } assert_tag :tag => 'a', :content => 'Move', - :attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2', + :attributes => { :href => '/issues/move/new?ids%5B%5D=1&ids%5B%5D=2', :class => 'icon-move' } assert_tag :tag => 'a', :content => 'Delete', :attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2', diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 51f8e71f6..af66f7417 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -85,8 +85,8 @@ class RoutingTest < ActionController::IntegrationTest # 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/perform_move", :controller => 'issues', :action => 'perform_move', :id => '1' + should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' + should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1' diff --git a/test/unit/helpers/issue_moves_helper_test.rb b/test/unit/helpers/issue_moves_helper_test.rb new file mode 100644 index 000000000..b2ffb6042 --- /dev/null +++ b/test/unit/helpers/issue_moves_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class IssueMovesHelperTest < ActionView::TestCase +end |