Mercurial > hg > soundsoftware-site
comparison test/functional/issue_moves_controller_test.rb @ 14:1d32c0a0efbf
* Update to SVN trunk (revisions 3892-4040)
| author | Chris Cannam |
|---|---|
| date | Wed, 25 Aug 2010 16:30:24 +0100 |
| parents | |
| children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
| 4:9cc62779c13a | 14:1d32c0a0efbf |
|---|---|
| 1 require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | |
| 3 class IssueMovesControllerTest < ActionController::TestCase | |
| 4 fixtures :all | |
| 5 | |
| 6 def setup | |
| 7 User.current = nil | |
| 8 end | |
| 9 | |
| 10 def test_create_one_issue_to_another_project | |
| 11 @request.session[:user_id] = 2 | |
| 12 post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' | |
| 13 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' | |
| 14 assert_equal 2, Issue.find(1).project_id | |
| 15 end | |
| 16 | |
| 17 def test_create_one_issue_to_another_project_should_follow_when_needed | |
| 18 @request.session[:user_id] = 2 | |
| 19 post :create, :id => 1, :new_project_id => 2, :follow => '1' | |
| 20 assert_redirected_to '/issues/1' | |
| 21 end | |
| 22 | |
| 23 def test_bulk_create_to_another_project | |
| 24 @request.session[:user_id] = 2 | |
| 25 post :create, :ids => [1, 2], :new_project_id => 2 | |
| 26 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' | |
| 27 # Issues moved to project 2 | |
| 28 assert_equal 2, Issue.find(1).project_id | |
| 29 assert_equal 2, Issue.find(2).project_id | |
| 30 # No tracker change | |
| 31 assert_equal 1, Issue.find(1).tracker_id | |
| 32 assert_equal 2, Issue.find(2).tracker_id | |
| 33 end | |
| 34 | |
| 35 def test_bulk_create_to_another_tracker | |
| 36 @request.session[:user_id] = 2 | |
| 37 post :create, :ids => [1, 2], :new_tracker_id => 2 | |
| 38 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' | |
| 39 assert_equal 2, Issue.find(1).tracker_id | |
| 40 assert_equal 2, Issue.find(2).tracker_id | |
| 41 end | |
| 42 | |
| 43 def test_bulk_copy_to_another_project | |
| 44 @request.session[:user_id] = 2 | |
| 45 assert_difference 'Issue.count', 2 do | |
| 46 assert_no_difference 'Project.find(1).issues.count' do | |
| 47 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'} | |
| 48 end | |
| 49 end | |
| 50 assert_redirected_to 'projects/ecookbook/issues' | |
| 51 end | |
| 52 | |
| 53 context "#create via bulk copy" do | |
| 54 should "allow not changing the issue's attributes" do | |
| 55 @request.session[:user_id] = 2 | |
| 56 issue_before_move = Issue.find(1) | |
| 57 assert_difference 'Issue.count', 1 do | |
| 58 assert_no_difference 'Project.find(1).issues.count' do | |
| 59 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' | |
| 60 end | |
| 61 end | |
| 62 issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2}) | |
| 63 assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id | |
| 64 assert_equal issue_before_move.status_id, issue_after_move.status_id | |
| 65 assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id | |
| 66 end | |
| 67 | |
| 68 should "allow changing the issue's attributes" do | |
| 69 # Fixes random test failure with Mysql | |
| 70 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results | |
| 71 Issue.delete_all("project_id=2") | |
| 72 | |
| 73 @request.session[:user_id] = 2 | |
| 74 assert_difference 'Issue.count', 2 do | |
| 75 assert_no_difference 'Project.find(1).issues.count' do | |
| 76 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' | |
| 77 end | |
| 78 end | |
| 79 | |
| 80 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) | |
| 81 assert_equal 2, copied_issues.size | |
| 82 copied_issues.each do |issue| | |
| 83 assert_equal 2, issue.project_id, "Project is incorrect" | |
| 84 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" | |
| 85 assert_equal 3, issue.status_id, "Status is incorrect" | |
| 86 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" | |
| 87 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" | |
| 88 end | |
| 89 end | |
| 90 end | |
| 91 | |
| 92 def test_copy_to_another_project_should_follow_when_needed | |
| 93 @request.session[:user_id] = 2 | |
| 94 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' | |
| 95 issue = Issue.first(:order => 'id DESC') | |
| 96 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue | |
| 97 end | |
| 98 | |
| 99 end |
