##// END OF EJS Templates
code layout clean up of 'should "allow adding a note when copying"' at test/functional/issue_moves_controller_test.rb...
Toshi MARUYAMA -
r7412:f21fd28917d2
parent child
Show More
@@ -1,171 +1,174
1 1 require File.expand_path('../../test_helper', __FILE__)
2 2
3 3 class IssueMovesControllerTest < ActionController::TestCase
4 4 fixtures :projects, :trackers, :issue_statuses, :issues,
5 5 :enumerations, :users, :issue_categories,
6 6 :projects_trackers,
7 7 :roles,
8 8 :member_roles,
9 9 :members,
10 10 :enabled_modules,
11 11 :workflows,
12 12 :journals, :journal_details
13 13
14 14 def setup
15 15 User.current = nil
16 16 end
17 17
18 18 def test_get_issue_moves_new
19 19 @request.session[:user_id] = 2
20 20 get :new, :id => 1
21 21
22 22 assert_tag :tag => 'option', :content => 'eCookbook',
23 23 :attributes => { :value => '1', :selected => 'selected' }
24 24 %w(new_tracker_id status_id priority_id assigned_to_id).each do |field|
25 25 assert_tag :tag => 'option', :content => '(No change)', :attributes => { :value => '' },
26 26 :parent => {:tag => 'select', :attributes => {:id => field}}
27 27 assert_no_tag :tag => 'option', :attributes => {:selected => 'selected'},
28 28 :parent => {:tag => 'select', :attributes => {:id => field}}
29 29 end
30 30
31 31 # Be sure we don't include inactive enumerations
32 32 assert ! IssuePriority.find(15).active?
33 33 assert_no_tag :option, :attributes => {:value => '15'},
34 34 :parent => {:tag => 'select', :attributes => {:id => 'priority_id'} }
35 35 end
36 36
37 37 def test_create_one_issue_to_another_project
38 38 @request.session[:user_id] = 2
39 39 post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
40 40 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
41 41 assert_equal 2, Issue.find(1).project_id
42 42 end
43 43
44 44 def test_create_one_issue_to_another_project_should_follow_when_needed
45 45 @request.session[:user_id] = 2
46 46 post :create, :id => 1, :new_project_id => 2, :follow => '1'
47 47 assert_redirected_to '/issues/1'
48 48 end
49 49
50 50 def test_bulk_create_to_another_project
51 51 @request.session[:user_id] = 2
52 52 post :create, :ids => [1, 2], :new_project_id => 2
53 53 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
54 54 # Issues moved to project 2
55 55 assert_equal 2, Issue.find(1).project_id
56 56 assert_equal 2, Issue.find(2).project_id
57 57 # No tracker change
58 58 assert_equal 1, Issue.find(1).tracker_id
59 59 assert_equal 2, Issue.find(2).tracker_id
60 60 end
61 61
62 62 def test_bulk_create_to_another_tracker
63 63 @request.session[:user_id] = 2
64 64 post :create, :ids => [1, 2], :new_tracker_id => 2
65 65 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
66 66 assert_equal 2, Issue.find(1).tracker_id
67 67 assert_equal 2, Issue.find(2).tracker_id
68 68 end
69 69
70 70 context "#create via bulk move" do
71 71 setup do
72 72 @request.session[:user_id] = 2
73 73 end
74 74
75 75 should "allow changing the issue priority" do
76 76 post :create, :ids => [1, 2], :priority_id => 6
77 77
78 78 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
79 79 assert_equal 6, Issue.find(1).priority_id
80 80 assert_equal 6, Issue.find(2).priority_id
81 81
82 82 end
83 83
84 84 should "allow adding a note when moving" do
85 85 post :create, :ids => [1, 2], :notes => 'Moving two issues'
86 86
87 87 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
88 88 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
89 89 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
90 90
91 91 end
92 92
93 93 end
94 94
95 95 def test_bulk_copy_to_another_project
96 96 @request.session[:user_id] = 2
97 97 assert_difference 'Issue.count', 2 do
98 98 assert_no_difference 'Project.find(1).issues.count' do
99 99 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
100 100 end
101 101 end
102 102 assert_redirected_to '/projects/ecookbook/issues'
103 103 end
104 104
105 105 context "#create via bulk copy" do
106 106 should "allow not changing the issue's attributes" do
107 107 @request.session[:user_id] = 2
108 108 issue_before_move = Issue.find(1)
109 109 assert_difference 'Issue.count', 1 do
110 110 assert_no_difference 'Project.find(1).issues.count' do
111 111 post :create, :ids => [1], :new_project_id => 2,
112 112 :copy_options => {:copy => '1'}, :new_tracker_id => '',
113 113 :assigned_to_id => '', :status_id => '',
114 114 :start_date => '', :due_date => ''
115 115 end
116 116 end
117 117 issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
118 118 assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id
119 119 assert_equal issue_before_move.status_id, issue_after_move.status_id
120 120 assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
121 121 end
122 122
123 123 should "allow changing the issue's attributes" do
124 124 # Fixes random test failure with Mysql
125 125 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
126 126 # doesn't return the expected results
127 127 Issue.delete_all("project_id=2")
128 128
129 129 @request.session[:user_id] = 2
130 130 assert_difference 'Issue.count', 2 do
131 131 assert_no_difference 'Project.find(1).issues.count' do
132 132 post :create, :ids => [1, 2], :new_project_id => 2,
133 133 :copy_options => {:copy => '1'}, :new_tracker_id => '',
134 134 :assigned_to_id => 4, :status_id => 3,
135 135 :start_date => '2009-12-01', :due_date => '2009-12-31'
136 136 end
137 137 end
138 138
139 139 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
140 140 assert_equal 2, copied_issues.size
141 141 copied_issues.each do |issue|
142 142 assert_equal 2, issue.project_id, "Project is incorrect"
143 143 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
144 144 assert_equal 3, issue.status_id, "Status is incorrect"
145 145 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
146 146 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
147 147 end
148 148 end
149 149
150 150 should "allow adding a note when copying" do
151 151 @request.session[:user_id] = 2
152 152 assert_difference 'Issue.count', 1 do
153 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'
153 post :create, :ids => [1], :copy_options => {:copy => '1'},
154 :notes => 'Copying one issue', :new_tracker_id => '',
155 :assigned_to_id => 4, :status_id => 3,
156 :start_date => '2009-12-01', :due_date => '2009-12-31'
154 157 end
155 158
156 159 issue = Issue.first(:order => 'id DESC')
157 160 assert_equal 1, issue.journals.size
158 161 journal = issue.journals.first
159 162 assert_equal 0, journal.details.size
160 163 assert_equal 'Copying one issue', journal.notes
161 164 end
162 165 end
163 166
164 167 def test_copy_to_another_project_should_follow_when_needed
165 168 @request.session[:user_id] = 2
166 169 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
167 170 issue = Issue.first(:order => 'id DESC')
168 171 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
169 172 end
170 173
171 174 end
General Comments 0
You need to be logged in to leave comments. Login now