##// END OF EJS Templates
code layout clean up of 'should "allow not changing the issue's attributes"' at test/functional/issue_moves_controller_test.rb...
Toshi MARUYAMA -
r7410:7e182848e59e
parent child
Show More
@@ -1,164 +1,167
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 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
111 post :create, :ids => [1], :new_project_id => 2,
112 :copy_options => {:copy => '1'}, :new_tracker_id => '',
113 :assigned_to_id => '', :status_id => '',
114 :start_date => '', :due_date => ''
112 115 end
113 116 end
114 117 issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
115 118 assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id
116 119 assert_equal issue_before_move.status_id, issue_after_move.status_id
117 120 assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
118 121 end
119 122
120 123 should "allow changing the issue's attributes" do
121 124 # Fixes random test failure with Mysql
122 125 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
123 126 Issue.delete_all("project_id=2")
124 127
125 128 @request.session[:user_id] = 2
126 129 assert_difference 'Issue.count', 2 do
127 130 assert_no_difference 'Project.find(1).issues.count' do
128 131 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'
129 132 end
130 133 end
131 134
132 135 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
133 136 assert_equal 2, copied_issues.size
134 137 copied_issues.each do |issue|
135 138 assert_equal 2, issue.project_id, "Project is incorrect"
136 139 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
137 140 assert_equal 3, issue.status_id, "Status is incorrect"
138 141 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
139 142 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
140 143 end
141 144 end
142 145
143 146 should "allow adding a note when copying" do
144 147 @request.session[:user_id] = 2
145 148 assert_difference 'Issue.count', 1 do
146 149 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'
147 150 end
148 151
149 152 issue = Issue.first(:order => 'id DESC')
150 153 assert_equal 1, issue.journals.size
151 154 journal = issue.journals.first
152 155 assert_equal 0, journal.details.size
153 156 assert_equal 'Copying one issue', journal.notes
154 157 end
155 158 end
156 159
157 160 def test_copy_to_another_project_should_follow_when_needed
158 161 @request.session[:user_id] = 2
159 162 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
160 163 issue = Issue.first(:order => 'id DESC')
161 164 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
162 165 end
163 166
164 167 end
General Comments 0
You need to be logged in to leave comments. Login now