To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / functional / .svn / text-base / issue_moves_controller_test.rb.svn-base @ 441:cbce1fd3b1b7
History | View | Annotate | Download (5.59 KB)
| 1 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__)
|
|---|---|---|---|
| 2 | 14:1d32c0a0efbf | Chris | |
| 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 | 37:94944d00e43c | chris | context "#create via bulk move" do |
| 44 | setup do |
||
| 45 | @request.session[:user_id] = 2 |
||
| 46 | end |
||
| 47 | |||
| 48 | should "allow changing the issue priority" do |
||
| 49 | post :create, :ids => [1, 2], :priority_id => 6 |
||
| 50 | |||
| 51 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
||
| 52 | assert_equal 6, Issue.find(1).priority_id |
||
| 53 | assert_equal 6, Issue.find(2).priority_id |
||
| 54 | |||
| 55 | end |
||
| 56 | |||
| 57 | should "allow adding a note when moving" do |
||
| 58 | post :create, :ids => [1, 2], :notes => 'Moving two issues' |
||
| 59 | |||
| 60 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
||
| 61 | 119:8661b858af72 | Chris | assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes |
| 62 | assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes |
||
| 63 | 37:94944d00e43c | chris | |
| 64 | end |
||
| 65 | |||
| 66 | end |
||
| 67 | |||
| 68 | 14:1d32c0a0efbf | Chris | def test_bulk_copy_to_another_project |
| 69 | @request.session[:user_id] = 2 |
||
| 70 | assert_difference 'Issue.count', 2 do |
||
| 71 | assert_no_difference 'Project.find(1).issues.count' do |
||
| 72 | post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
|
||
| 73 | end |
||
| 74 | end |
||
| 75 | 37:94944d00e43c | chris | assert_redirected_to '/projects/ecookbook/issues' |
| 76 | 14:1d32c0a0efbf | Chris | end |
| 77 | |||
| 78 | context "#create via bulk copy" do |
||
| 79 | should "allow not changing the issue's attributes" do |
||
| 80 | @request.session[:user_id] = 2 |
||
| 81 | issue_before_move = Issue.find(1) |
||
| 82 | assert_difference 'Issue.count', 1 do |
||
| 83 | assert_no_difference 'Project.find(1).issues.count' do |
||
| 84 | post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
|
||
| 85 | end |
||
| 86 | end |
||
| 87 | issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
|
||
| 88 | assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id |
||
| 89 | assert_equal issue_before_move.status_id, issue_after_move.status_id |
||
| 90 | assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id |
||
| 91 | end |
||
| 92 | |||
| 93 | should "allow changing the issue's attributes" do |
||
| 94 | # Fixes random test failure with Mysql |
||
| 95 | # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
|
||
| 96 | Issue.delete_all("project_id=2")
|
||
| 97 | |||
| 98 | @request.session[:user_id] = 2 |
||
| 99 | assert_difference 'Issue.count', 2 do |
||
| 100 | assert_no_difference 'Project.find(1).issues.count' do |
||
| 101 | 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'
|
||
| 102 | end |
||
| 103 | end |
||
| 104 | |||
| 105 | copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
|
||
| 106 | assert_equal 2, copied_issues.size |
||
| 107 | copied_issues.each do |issue| |
||
| 108 | assert_equal 2, issue.project_id, "Project is incorrect" |
||
| 109 | assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" |
||
| 110 | assert_equal 3, issue.status_id, "Status is incorrect" |
||
| 111 | assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" |
||
| 112 | assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" |
||
| 113 | end |
||
| 114 | end |
||
| 115 | 441:cbce1fd3b1b7 | Chris | |
| 116 | should "allow adding a note when copying" do |
||
| 117 | @request.session[:user_id] = 2 |
||
| 118 | assert_difference 'Issue.count', 1 do |
||
| 119 | post :create, :ids => [1], :copy_options => {:copy => '1'}, :notes => 'Copying one issue', :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31'
|
||
| 120 | end |
||
| 121 | |||
| 122 | issue = Issue.first(:order => 'id DESC') |
||
| 123 | assert_equal 1, issue.journals.size |
||
| 124 | journal = issue.journals.first |
||
| 125 | assert_equal 0, journal.details.size |
||
| 126 | assert_equal 'Copying one issue', journal.notes |
||
| 127 | end |
||
| 128 | 14:1d32c0a0efbf | Chris | end |
| 129 | |||
| 130 | def test_copy_to_another_project_should_follow_when_needed |
||
| 131 | @request.session[:user_id] = 2 |
||
| 132 | post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
|
||
| 133 | issue = Issue.first(:order => 'id DESC') |
||
| 134 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue |
||
| 135 | end |
||
| 136 | |||
| 137 | end |