@@ -1,486 +1,486 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'issues_controller' |
|
19 | require 'issues_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class IssuesController; def rescue_action(e) raise e end; end |
|
22 | class IssuesController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class IssuesControllerTest < Test::Unit::TestCase |
|
24 | class IssuesControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, |
|
25 | fixtures :projects, | |
26 | :users, |
|
26 | :users, | |
27 | :roles, |
|
27 | :roles, | |
28 | :members, |
|
28 | :members, | |
29 | :issues, |
|
29 | :issues, | |
30 | :issue_statuses, |
|
30 | :issue_statuses, | |
31 | :trackers, |
|
31 | :trackers, | |
32 | :projects_trackers, |
|
32 | :projects_trackers, | |
33 | :issue_categories, |
|
33 | :issue_categories, | |
34 | :enabled_modules, |
|
34 | :enabled_modules, | |
35 | :enumerations, |
|
35 | :enumerations, | |
36 | :attachments, |
|
36 | :attachments, | |
37 | :workflows, |
|
37 | :workflows, | |
38 | :custom_fields, |
|
38 | :custom_fields, | |
39 | :custom_values, |
|
39 | :custom_values, | |
40 | :custom_fields_trackers, |
|
40 | :custom_fields_trackers, | |
41 | :time_entries |
|
41 | :time_entries | |
42 |
|
42 | |||
43 | def setup |
|
43 | def setup | |
44 | @controller = IssuesController.new |
|
44 | @controller = IssuesController.new | |
45 | @request = ActionController::TestRequest.new |
|
45 | @request = ActionController::TestRequest.new | |
46 | @response = ActionController::TestResponse.new |
|
46 | @response = ActionController::TestResponse.new | |
47 | User.current = nil |
|
47 | User.current = nil | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | def test_index |
|
50 | def test_index | |
51 | get :index |
|
51 | get :index | |
52 | assert_response :success |
|
52 | assert_response :success | |
53 | assert_template 'index.rhtml' |
|
53 | assert_template 'index.rhtml' | |
54 | assert_not_nil assigns(:issues) |
|
54 | assert_not_nil assigns(:issues) | |
55 | assert_nil assigns(:project) |
|
55 | assert_nil assigns(:project) | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_index_with_project |
|
58 | def test_index_with_project | |
59 | get :index, :project_id => 1 |
|
59 | get :index, :project_id => 1 | |
60 | assert_response :success |
|
60 | assert_response :success | |
61 | assert_template 'index.rhtml' |
|
61 | assert_template 'index.rhtml' | |
62 | assert_not_nil assigns(:issues) |
|
62 | assert_not_nil assigns(:issues) | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | def test_index_with_project_and_filter |
|
65 | def test_index_with_project_and_filter | |
66 | get :index, :project_id => 1, :set_filter => 1 |
|
66 | get :index, :project_id => 1, :set_filter => 1 | |
67 | assert_response :success |
|
67 | assert_response :success | |
68 | assert_template 'index.rhtml' |
|
68 | assert_template 'index.rhtml' | |
69 | assert_not_nil assigns(:issues) |
|
69 | assert_not_nil assigns(:issues) | |
70 | end |
|
70 | end | |
71 |
|
71 | |||
72 | def test_index_csv_with_project |
|
72 | def test_index_csv_with_project | |
73 | get :index, :format => 'csv' |
|
73 | get :index, :format => 'csv' | |
74 | assert_response :success |
|
74 | assert_response :success | |
75 | assert_not_nil assigns(:issues) |
|
75 | assert_not_nil assigns(:issues) | |
76 | assert_equal 'text/csv', @response.content_type |
|
76 | assert_equal 'text/csv', @response.content_type | |
77 |
|
77 | |||
78 | get :index, :project_id => 1, :format => 'csv' |
|
78 | get :index, :project_id => 1, :format => 'csv' | |
79 | assert_response :success |
|
79 | assert_response :success | |
80 | assert_not_nil assigns(:issues) |
|
80 | assert_not_nil assigns(:issues) | |
81 | assert_equal 'text/csv', @response.content_type |
|
81 | assert_equal 'text/csv', @response.content_type | |
82 | end |
|
82 | end | |
83 |
|
83 | |||
84 | def test_index_pdf |
|
84 | def test_index_pdf | |
85 | get :index, :format => 'pdf' |
|
85 | get :index, :format => 'pdf' | |
86 | assert_response :success |
|
86 | assert_response :success | |
87 | assert_not_nil assigns(:issues) |
|
87 | assert_not_nil assigns(:issues) | |
88 | assert_equal 'application/pdf', @response.content_type |
|
88 | assert_equal 'application/pdf', @response.content_type | |
89 |
|
89 | |||
90 | get :index, :project_id => 1, :format => 'pdf' |
|
90 | get :index, :project_id => 1, :format => 'pdf' | |
91 | assert_response :success |
|
91 | assert_response :success | |
92 | assert_not_nil assigns(:issues) |
|
92 | assert_not_nil assigns(:issues) | |
93 | assert_equal 'application/pdf', @response.content_type |
|
93 | assert_equal 'application/pdf', @response.content_type | |
94 | end |
|
94 | end | |
95 |
|
95 | |||
96 | def test_changes |
|
96 | def test_changes | |
97 | get :changes, :project_id => 1 |
|
97 | get :changes, :project_id => 1 | |
98 | assert_response :success |
|
98 | assert_response :success | |
99 | assert_not_nil assigns(:journals) |
|
99 | assert_not_nil assigns(:journals) | |
100 | assert_equal 'application/atom+xml', @response.content_type |
|
100 | assert_equal 'application/atom+xml', @response.content_type | |
101 | end |
|
101 | end | |
102 |
|
102 | |||
103 | def test_show_by_anonymous |
|
103 | def test_show_by_anonymous | |
104 | get :show, :id => 1 |
|
104 | get :show, :id => 1 | |
105 | assert_response :success |
|
105 | assert_response :success | |
106 | assert_template 'show.rhtml' |
|
106 | assert_template 'show.rhtml' | |
107 | assert_not_nil assigns(:issue) |
|
107 | assert_not_nil assigns(:issue) | |
108 | assert_equal Issue.find(1), assigns(:issue) |
|
108 | assert_equal Issue.find(1), assigns(:issue) | |
109 |
|
109 | |||
110 | # anonymous role is allowed to add a note |
|
110 | # anonymous role is allowed to add a note | |
111 | assert_tag :tag => 'form', |
|
111 | assert_tag :tag => 'form', | |
112 | :descendant => { :tag => 'fieldset', |
|
112 | :descendant => { :tag => 'fieldset', | |
113 | :child => { :tag => 'legend', |
|
113 | :child => { :tag => 'legend', | |
114 | :content => /Notes/ } } |
|
114 | :content => /Notes/ } } | |
115 | end |
|
115 | end | |
116 |
|
116 | |||
117 | def test_show_by_manager |
|
117 | def test_show_by_manager | |
118 | @request.session[:user_id] = 2 |
|
118 | @request.session[:user_id] = 2 | |
119 | get :show, :id => 1 |
|
119 | get :show, :id => 1 | |
120 | assert_response :success |
|
120 | assert_response :success | |
121 |
|
121 | |||
122 | assert_tag :tag => 'form', |
|
122 | assert_tag :tag => 'form', | |
123 | :descendant => { :tag => 'fieldset', |
|
123 | :descendant => { :tag => 'fieldset', | |
124 | :child => { :tag => 'legend', |
|
124 | :child => { :tag => 'legend', | |
125 | :content => /Change properties/ } }, |
|
125 | :content => /Change properties/ } }, | |
126 | :descendant => { :tag => 'fieldset', |
|
126 | :descendant => { :tag => 'fieldset', | |
127 | :child => { :tag => 'legend', |
|
127 | :child => { :tag => 'legend', | |
128 | :content => /Log time/ } }, |
|
128 | :content => /Log time/ } }, | |
129 | :descendant => { :tag => 'fieldset', |
|
129 | :descendant => { :tag => 'fieldset', | |
130 | :child => { :tag => 'legend', |
|
130 | :child => { :tag => 'legend', | |
131 | :content => /Notes/ } } |
|
131 | :content => /Notes/ } } | |
132 | end |
|
132 | end | |
133 |
|
133 | |||
134 | def test_get_new |
|
134 | def test_get_new | |
135 | @request.session[:user_id] = 2 |
|
135 | @request.session[:user_id] = 2 | |
136 | get :new, :project_id => 1, :tracker_id => 1 |
|
136 | get :new, :project_id => 1, :tracker_id => 1 | |
137 | assert_response :success |
|
137 | assert_response :success | |
138 | assert_template 'new' |
|
138 | assert_template 'new' | |
139 |
|
139 | |||
140 | assert_tag :tag => 'input', :attributes => { :name => 'custom_fields[2]', |
|
140 | assert_tag :tag => 'input', :attributes => { :name => 'custom_fields[2]', | |
141 | :value => 'Default string' } |
|
141 | :value => 'Default string' } | |
142 | end |
|
142 | end | |
143 |
|
143 | |||
144 | def test_get_new_without_tracker_id |
|
144 | def test_get_new_without_tracker_id | |
145 | @request.session[:user_id] = 2 |
|
145 | @request.session[:user_id] = 2 | |
146 | get :new, :project_id => 1 |
|
146 | get :new, :project_id => 1 | |
147 | assert_response :success |
|
147 | assert_response :success | |
148 | assert_template 'new' |
|
148 | assert_template 'new' | |
149 |
|
149 | |||
150 | issue = assigns(:issue) |
|
150 | issue = assigns(:issue) | |
151 | assert_not_nil issue |
|
151 | assert_not_nil issue | |
152 | assert_equal Project.find(1).trackers.first, issue.tracker |
|
152 | assert_equal Project.find(1).trackers.first, issue.tracker | |
153 | end |
|
153 | end | |
154 |
|
154 | |||
155 | def test_update_new_form |
|
155 | def test_update_new_form | |
156 | @request.session[:user_id] = 2 |
|
156 | @request.session[:user_id] = 2 | |
157 | xhr :post, :new, :project_id => 1, |
|
157 | xhr :post, :new, :project_id => 1, | |
158 | :issue => {:tracker_id => 2, |
|
158 | :issue => {:tracker_id => 2, | |
159 | :subject => 'This is the test_new issue', |
|
159 | :subject => 'This is the test_new issue', | |
160 | :description => 'This is the description', |
|
160 | :description => 'This is the description', | |
161 | :priority_id => 5} |
|
161 | :priority_id => 5} | |
162 | assert_response :success |
|
162 | assert_response :success | |
163 | assert_template 'new' |
|
163 | assert_template 'new' | |
164 | end |
|
164 | end | |
165 |
|
165 | |||
166 | def test_post_new |
|
166 | def test_post_new | |
167 | @request.session[:user_id] = 2 |
|
167 | @request.session[:user_id] = 2 | |
168 | post :new, :project_id => 1, |
|
168 | post :new, :project_id => 1, | |
169 | :issue => {:tracker_id => 1, |
|
169 | :issue => {:tracker_id => 1, | |
170 | :subject => 'This is the test_new issue', |
|
170 | :subject => 'This is the test_new issue', | |
171 | :description => 'This is the description', |
|
171 | :description => 'This is the description', | |
172 | :priority_id => 5}, |
|
172 | :priority_id => 5}, | |
173 | :custom_fields => {'2' => 'Value for field 2'} |
|
173 | :custom_fields => {'2' => 'Value for field 2'} | |
174 |
assert_redirected_to ' |
|
174 | assert_redirected_to 'issues/show' | |
175 |
|
175 | |||
176 | issue = Issue.find_by_subject('This is the test_new issue') |
|
176 | issue = Issue.find_by_subject('This is the test_new issue') | |
177 | assert_not_nil issue |
|
177 | assert_not_nil issue | |
178 | assert_equal 2, issue.author_id |
|
178 | assert_equal 2, issue.author_id | |
179 | v = issue.custom_values.find_by_custom_field_id(2) |
|
179 | v = issue.custom_values.find_by_custom_field_id(2) | |
180 | assert_not_nil v |
|
180 | assert_not_nil v | |
181 | assert_equal 'Value for field 2', v.value |
|
181 | assert_equal 'Value for field 2', v.value | |
182 | end |
|
182 | end | |
183 |
|
183 | |||
184 | def test_copy_issue |
|
184 | def test_copy_issue | |
185 | @request.session[:user_id] = 2 |
|
185 | @request.session[:user_id] = 2 | |
186 | get :new, :project_id => 1, :copy_from => 1 |
|
186 | get :new, :project_id => 1, :copy_from => 1 | |
187 | assert_template 'new' |
|
187 | assert_template 'new' | |
188 | assert_not_nil assigns(:issue) |
|
188 | assert_not_nil assigns(:issue) | |
189 | orig = Issue.find(1) |
|
189 | orig = Issue.find(1) | |
190 | assert_equal orig.subject, assigns(:issue).subject |
|
190 | assert_equal orig.subject, assigns(:issue).subject | |
191 | end |
|
191 | end | |
192 |
|
192 | |||
193 | def test_get_edit |
|
193 | def test_get_edit | |
194 | @request.session[:user_id] = 2 |
|
194 | @request.session[:user_id] = 2 | |
195 | get :edit, :id => 1 |
|
195 | get :edit, :id => 1 | |
196 | assert_response :success |
|
196 | assert_response :success | |
197 | assert_template 'edit' |
|
197 | assert_template 'edit' | |
198 | assert_not_nil assigns(:issue) |
|
198 | assert_not_nil assigns(:issue) | |
199 | assert_equal Issue.find(1), assigns(:issue) |
|
199 | assert_equal Issue.find(1), assigns(:issue) | |
200 | end |
|
200 | end | |
201 |
|
201 | |||
202 | def test_get_edit_with_params |
|
202 | def test_get_edit_with_params | |
203 | @request.session[:user_id] = 2 |
|
203 | @request.session[:user_id] = 2 | |
204 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 } |
|
204 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 } | |
205 | assert_response :success |
|
205 | assert_response :success | |
206 | assert_template 'edit' |
|
206 | assert_template 'edit' | |
207 |
|
207 | |||
208 | issue = assigns(:issue) |
|
208 | issue = assigns(:issue) | |
209 | assert_not_nil issue |
|
209 | assert_not_nil issue | |
210 |
|
210 | |||
211 | assert_equal 5, issue.status_id |
|
211 | assert_equal 5, issue.status_id | |
212 | assert_tag :select, :attributes => { :name => 'issue[status_id]' }, |
|
212 | assert_tag :select, :attributes => { :name => 'issue[status_id]' }, | |
213 | :child => { :tag => 'option', |
|
213 | :child => { :tag => 'option', | |
214 | :content => 'Closed', |
|
214 | :content => 'Closed', | |
215 | :attributes => { :selected => 'selected' } } |
|
215 | :attributes => { :selected => 'selected' } } | |
216 |
|
216 | |||
217 | assert_equal 7, issue.priority_id |
|
217 | assert_equal 7, issue.priority_id | |
218 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, |
|
218 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, | |
219 | :child => { :tag => 'option', |
|
219 | :child => { :tag => 'option', | |
220 | :content => 'Urgent', |
|
220 | :content => 'Urgent', | |
221 | :attributes => { :selected => 'selected' } } |
|
221 | :attributes => { :selected => 'selected' } } | |
222 | end |
|
222 | end | |
223 |
|
223 | |||
224 | def test_post_edit |
|
224 | def test_post_edit | |
225 | @request.session[:user_id] = 2 |
|
225 | @request.session[:user_id] = 2 | |
226 | ActionMailer::Base.deliveries.clear |
|
226 | ActionMailer::Base.deliveries.clear | |
227 |
|
227 | |||
228 | issue = Issue.find(1) |
|
228 | issue = Issue.find(1) | |
229 | old_subject = issue.subject |
|
229 | old_subject = issue.subject | |
230 | new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' |
|
230 | new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' | |
231 |
|
231 | |||
232 | post :edit, :id => 1, :issue => {:subject => new_subject} |
|
232 | post :edit, :id => 1, :issue => {:subject => new_subject} | |
233 | assert_redirected_to 'issues/show/1' |
|
233 | assert_redirected_to 'issues/show/1' | |
234 | issue.reload |
|
234 | issue.reload | |
235 | assert_equal new_subject, issue.subject |
|
235 | assert_equal new_subject, issue.subject | |
236 |
|
236 | |||
237 | mail = ActionMailer::Base.deliveries.last |
|
237 | mail = ActionMailer::Base.deliveries.last | |
238 | assert_kind_of TMail::Mail, mail |
|
238 | assert_kind_of TMail::Mail, mail | |
239 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
239 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") | |
240 | assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}") |
|
240 | assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}") | |
241 | end |
|
241 | end | |
242 |
|
242 | |||
243 | def test_post_edit_with_status_and_assignee_change |
|
243 | def test_post_edit_with_status_and_assignee_change | |
244 | issue = Issue.find(1) |
|
244 | issue = Issue.find(1) | |
245 | assert_equal 1, issue.status_id |
|
245 | assert_equal 1, issue.status_id | |
246 | @request.session[:user_id] = 2 |
|
246 | @request.session[:user_id] = 2 | |
247 | post :edit, |
|
247 | post :edit, | |
248 | :id => 1, |
|
248 | :id => 1, | |
249 | :issue => { :status_id => 2, :assigned_to_id => 3 }, |
|
249 | :issue => { :status_id => 2, :assigned_to_id => 3 }, | |
250 | :notes => 'Assigned to dlopper' |
|
250 | :notes => 'Assigned to dlopper' | |
251 | assert_redirected_to 'issues/show/1' |
|
251 | assert_redirected_to 'issues/show/1' | |
252 | issue.reload |
|
252 | issue.reload | |
253 | assert_equal 2, issue.status_id |
|
253 | assert_equal 2, issue.status_id | |
254 | j = issue.journals.find(:first, :order => 'id DESC') |
|
254 | j = issue.journals.find(:first, :order => 'id DESC') | |
255 | assert_equal 'Assigned to dlopper', j.notes |
|
255 | assert_equal 'Assigned to dlopper', j.notes | |
256 | assert_equal 2, j.details.size |
|
256 | assert_equal 2, j.details.size | |
257 |
|
257 | |||
258 | mail = ActionMailer::Base.deliveries.last |
|
258 | mail = ActionMailer::Base.deliveries.last | |
259 | assert mail.body.include?("Status changed from New to Assigned") |
|
259 | assert mail.body.include?("Status changed from New to Assigned") | |
260 | end |
|
260 | end | |
261 |
|
261 | |||
262 | def test_post_edit_with_note_only |
|
262 | def test_post_edit_with_note_only | |
263 | notes = 'Note added by IssuesControllerTest#test_update_with_note_only' |
|
263 | notes = 'Note added by IssuesControllerTest#test_update_with_note_only' | |
264 | # anonymous user |
|
264 | # anonymous user | |
265 | post :edit, |
|
265 | post :edit, | |
266 | :id => 1, |
|
266 | :id => 1, | |
267 | :notes => notes |
|
267 | :notes => notes | |
268 | assert_redirected_to 'issues/show/1' |
|
268 | assert_redirected_to 'issues/show/1' | |
269 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
269 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') | |
270 | assert_equal notes, j.notes |
|
270 | assert_equal notes, j.notes | |
271 | assert_equal 0, j.details.size |
|
271 | assert_equal 0, j.details.size | |
272 | assert_equal User.anonymous, j.user |
|
272 | assert_equal User.anonymous, j.user | |
273 |
|
273 | |||
274 | mail = ActionMailer::Base.deliveries.last |
|
274 | mail = ActionMailer::Base.deliveries.last | |
275 | assert mail.body.include?(notes) |
|
275 | assert mail.body.include?(notes) | |
276 | end |
|
276 | end | |
277 |
|
277 | |||
278 | def test_post_edit_with_note_and_spent_time |
|
278 | def test_post_edit_with_note_and_spent_time | |
279 | @request.session[:user_id] = 2 |
|
279 | @request.session[:user_id] = 2 | |
280 | spent_hours_before = Issue.find(1).spent_hours |
|
280 | spent_hours_before = Issue.find(1).spent_hours | |
281 | post :edit, |
|
281 | post :edit, | |
282 | :id => 1, |
|
282 | :id => 1, | |
283 | :notes => '2.5 hours added', |
|
283 | :notes => '2.5 hours added', | |
284 | :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } |
|
284 | :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } | |
285 | assert_redirected_to 'issues/show/1' |
|
285 | assert_redirected_to 'issues/show/1' | |
286 |
|
286 | |||
287 | issue = Issue.find(1) |
|
287 | issue = Issue.find(1) | |
288 |
|
288 | |||
289 | j = issue.journals.find(:first, :order => 'id DESC') |
|
289 | j = issue.journals.find(:first, :order => 'id DESC') | |
290 | assert_equal '2.5 hours added', j.notes |
|
290 | assert_equal '2.5 hours added', j.notes | |
291 | assert_equal 0, j.details.size |
|
291 | assert_equal 0, j.details.size | |
292 |
|
292 | |||
293 | t = issue.time_entries.find(:first, :order => 'id DESC') |
|
293 | t = issue.time_entries.find(:first, :order => 'id DESC') | |
294 | assert_not_nil t |
|
294 | assert_not_nil t | |
295 | assert_equal 2.5, t.hours |
|
295 | assert_equal 2.5, t.hours | |
296 | assert_equal spent_hours_before + 2.5, issue.spent_hours |
|
296 | assert_equal spent_hours_before + 2.5, issue.spent_hours | |
297 | end |
|
297 | end | |
298 |
|
298 | |||
299 | def test_post_edit_with_attachment_only |
|
299 | def test_post_edit_with_attachment_only | |
300 | # anonymous user |
|
300 | # anonymous user | |
301 | post :edit, |
|
301 | post :edit, | |
302 | :id => 1, |
|
302 | :id => 1, | |
303 | :notes => '', |
|
303 | :notes => '', | |
304 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}} |
|
304 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}} | |
305 | assert_redirected_to 'issues/show/1' |
|
305 | assert_redirected_to 'issues/show/1' | |
306 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
306 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') | |
307 | assert j.notes.blank? |
|
307 | assert j.notes.blank? | |
308 | assert_equal 1, j.details.size |
|
308 | assert_equal 1, j.details.size | |
309 | assert_equal 'testfile.txt', j.details.first.value |
|
309 | assert_equal 'testfile.txt', j.details.first.value | |
310 | assert_equal User.anonymous, j.user |
|
310 | assert_equal User.anonymous, j.user | |
311 |
|
311 | |||
312 | mail = ActionMailer::Base.deliveries.last |
|
312 | mail = ActionMailer::Base.deliveries.last | |
313 | assert mail.body.include?('testfile.txt') |
|
313 | assert mail.body.include?('testfile.txt') | |
314 | end |
|
314 | end | |
315 |
|
315 | |||
316 | def test_post_edit_with_no_change |
|
316 | def test_post_edit_with_no_change | |
317 | issue = Issue.find(1) |
|
317 | issue = Issue.find(1) | |
318 | issue.journals.clear |
|
318 | issue.journals.clear | |
319 | ActionMailer::Base.deliveries.clear |
|
319 | ActionMailer::Base.deliveries.clear | |
320 |
|
320 | |||
321 | post :edit, |
|
321 | post :edit, | |
322 | :id => 1, |
|
322 | :id => 1, | |
323 | :notes => '' |
|
323 | :notes => '' | |
324 | assert_redirected_to 'issues/show/1' |
|
324 | assert_redirected_to 'issues/show/1' | |
325 |
|
325 | |||
326 | issue.reload |
|
326 | issue.reload | |
327 | assert issue.journals.empty? |
|
327 | assert issue.journals.empty? | |
328 | # No email should be sent |
|
328 | # No email should be sent | |
329 | assert ActionMailer::Base.deliveries.empty? |
|
329 | assert ActionMailer::Base.deliveries.empty? | |
330 | end |
|
330 | end | |
331 |
|
331 | |||
332 | def test_bulk_edit |
|
332 | def test_bulk_edit | |
333 | @request.session[:user_id] = 2 |
|
333 | @request.session[:user_id] = 2 | |
334 | # update issues priority |
|
334 | # update issues priority | |
335 | post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' |
|
335 | post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' | |
336 | assert_response 302 |
|
336 | assert_response 302 | |
337 | # check that the issues were updated |
|
337 | # check that the issues were updated | |
338 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
338 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} | |
339 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes |
|
339 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes | |
340 | end |
|
340 | end | |
341 |
|
341 | |||
342 | def test_move_one_issue_to_another_project |
|
342 | def test_move_one_issue_to_another_project | |
343 | @request.session[:user_id] = 1 |
|
343 | @request.session[:user_id] = 1 | |
344 | post :move, :id => 1, :new_project_id => 2 |
|
344 | post :move, :id => 1, :new_project_id => 2 | |
345 | assert_redirected_to 'projects/ecookbook/issues' |
|
345 | assert_redirected_to 'projects/ecookbook/issues' | |
346 | assert_equal 2, Issue.find(1).project_id |
|
346 | assert_equal 2, Issue.find(1).project_id | |
347 | end |
|
347 | end | |
348 |
|
348 | |||
349 | def test_bulk_move_to_another_project |
|
349 | def test_bulk_move_to_another_project | |
350 | @request.session[:user_id] = 1 |
|
350 | @request.session[:user_id] = 1 | |
351 | post :move, :ids => [1, 2], :new_project_id => 2 |
|
351 | post :move, :ids => [1, 2], :new_project_id => 2 | |
352 | assert_redirected_to 'projects/ecookbook/issues' |
|
352 | assert_redirected_to 'projects/ecookbook/issues' | |
353 | # Issues moved to project 2 |
|
353 | # Issues moved to project 2 | |
354 | assert_equal 2, Issue.find(1).project_id |
|
354 | assert_equal 2, Issue.find(1).project_id | |
355 | assert_equal 2, Issue.find(2).project_id |
|
355 | assert_equal 2, Issue.find(2).project_id | |
356 | # No tracker change |
|
356 | # No tracker change | |
357 | assert_equal 1, Issue.find(1).tracker_id |
|
357 | assert_equal 1, Issue.find(1).tracker_id | |
358 | assert_equal 2, Issue.find(2).tracker_id |
|
358 | assert_equal 2, Issue.find(2).tracker_id | |
359 | end |
|
359 | end | |
360 |
|
360 | |||
361 | def test_bulk_move_to_another_tracker |
|
361 | def test_bulk_move_to_another_tracker | |
362 | @request.session[:user_id] = 1 |
|
362 | @request.session[:user_id] = 1 | |
363 | post :move, :ids => [1, 2], :new_tracker_id => 2 |
|
363 | post :move, :ids => [1, 2], :new_tracker_id => 2 | |
364 | assert_redirected_to 'projects/ecookbook/issues' |
|
364 | assert_redirected_to 'projects/ecookbook/issues' | |
365 | assert_equal 2, Issue.find(1).tracker_id |
|
365 | assert_equal 2, Issue.find(1).tracker_id | |
366 | assert_equal 2, Issue.find(2).tracker_id |
|
366 | assert_equal 2, Issue.find(2).tracker_id | |
367 | end |
|
367 | end | |
368 |
|
368 | |||
369 | def test_context_menu_one_issue |
|
369 | def test_context_menu_one_issue | |
370 | @request.session[:user_id] = 2 |
|
370 | @request.session[:user_id] = 2 | |
371 | get :context_menu, :ids => [1] |
|
371 | get :context_menu, :ids => [1] | |
372 | assert_response :success |
|
372 | assert_response :success | |
373 | assert_template 'context_menu' |
|
373 | assert_template 'context_menu' | |
374 | assert_tag :tag => 'a', :content => 'Edit', |
|
374 | assert_tag :tag => 'a', :content => 'Edit', | |
375 | :attributes => { :href => '/issues/edit/1', |
|
375 | :attributes => { :href => '/issues/edit/1', | |
376 | :class => 'icon-edit' } |
|
376 | :class => 'icon-edit' } | |
377 | assert_tag :tag => 'a', :content => 'Closed', |
|
377 | assert_tag :tag => 'a', :content => 'Closed', | |
378 | :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5', |
|
378 | :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5', | |
379 | :class => '' } |
|
379 | :class => '' } | |
380 | assert_tag :tag => 'a', :content => 'Immediate', |
|
380 | assert_tag :tag => 'a', :content => 'Immediate', | |
381 | :attributes => { :href => '/issues/edit/1?issue%5Bpriority_id%5D=8', |
|
381 | :attributes => { :href => '/issues/edit/1?issue%5Bpriority_id%5D=8', | |
382 | :class => '' } |
|
382 | :class => '' } | |
383 | assert_tag :tag => 'a', :content => 'Dave Lopper', |
|
383 | assert_tag :tag => 'a', :content => 'Dave Lopper', | |
384 | :attributes => { :href => '/issues/edit/1?issue%5Bassigned_to_id%5D=3', |
|
384 | :attributes => { :href => '/issues/edit/1?issue%5Bassigned_to_id%5D=3', | |
385 | :class => '' } |
|
385 | :class => '' } | |
386 | assert_tag :tag => 'a', :content => 'Copy', |
|
386 | assert_tag :tag => 'a', :content => 'Copy', | |
387 | :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1', |
|
387 | :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1', | |
388 | :class => 'icon-copy' } |
|
388 | :class => 'icon-copy' } | |
389 | assert_tag :tag => 'a', :content => 'Move', |
|
389 | assert_tag :tag => 'a', :content => 'Move', | |
390 | :attributes => { :href => '/issues/move?ids%5B%5D=1', |
|
390 | :attributes => { :href => '/issues/move?ids%5B%5D=1', | |
391 | :class => 'icon-move' } |
|
391 | :class => 'icon-move' } | |
392 | assert_tag :tag => 'a', :content => 'Delete', |
|
392 | assert_tag :tag => 'a', :content => 'Delete', | |
393 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1', |
|
393 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1', | |
394 | :class => 'icon-del' } |
|
394 | :class => 'icon-del' } | |
395 | end |
|
395 | end | |
396 |
|
396 | |||
397 | def test_context_menu_one_issue_by_anonymous |
|
397 | def test_context_menu_one_issue_by_anonymous | |
398 | get :context_menu, :ids => [1] |
|
398 | get :context_menu, :ids => [1] | |
399 | assert_response :success |
|
399 | assert_response :success | |
400 | assert_template 'context_menu' |
|
400 | assert_template 'context_menu' | |
401 | assert_tag :tag => 'a', :content => 'Delete', |
|
401 | assert_tag :tag => 'a', :content => 'Delete', | |
402 | :attributes => { :href => '#', |
|
402 | :attributes => { :href => '#', | |
403 | :class => 'icon-del disabled' } |
|
403 | :class => 'icon-del disabled' } | |
404 | end |
|
404 | end | |
405 |
|
405 | |||
406 | def test_context_menu_multiple_issues_of_same_project |
|
406 | def test_context_menu_multiple_issues_of_same_project | |
407 | @request.session[:user_id] = 2 |
|
407 | @request.session[:user_id] = 2 | |
408 | get :context_menu, :ids => [1, 2] |
|
408 | get :context_menu, :ids => [1, 2] | |
409 | assert_response :success |
|
409 | assert_response :success | |
410 | assert_template 'context_menu' |
|
410 | assert_template 'context_menu' | |
411 | assert_tag :tag => 'a', :content => 'Edit', |
|
411 | assert_tag :tag => 'a', :content => 'Edit', | |
412 | :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', |
|
412 | :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', | |
413 | :class => 'icon-edit' } |
|
413 | :class => 'icon-edit' } | |
414 | assert_tag :tag => 'a', :content => 'Move', |
|
414 | assert_tag :tag => 'a', :content => 'Move', | |
415 | :attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2', |
|
415 | :attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2', | |
416 | :class => 'icon-move' } |
|
416 | :class => 'icon-move' } | |
417 | assert_tag :tag => 'a', :content => 'Delete', |
|
417 | assert_tag :tag => 'a', :content => 'Delete', | |
418 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2', |
|
418 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2', | |
419 | :class => 'icon-del' } |
|
419 | :class => 'icon-del' } | |
420 | end |
|
420 | end | |
421 |
|
421 | |||
422 | def test_context_menu_multiple_issues_of_different_project |
|
422 | def test_context_menu_multiple_issues_of_different_project | |
423 | @request.session[:user_id] = 2 |
|
423 | @request.session[:user_id] = 2 | |
424 | get :context_menu, :ids => [1, 2, 4] |
|
424 | get :context_menu, :ids => [1, 2, 4] | |
425 | assert_response :success |
|
425 | assert_response :success | |
426 | assert_template 'context_menu' |
|
426 | assert_template 'context_menu' | |
427 | assert_tag :tag => 'a', :content => 'Delete', |
|
427 | assert_tag :tag => 'a', :content => 'Delete', | |
428 | :attributes => { :href => '#', |
|
428 | :attributes => { :href => '#', | |
429 | :class => 'icon-del disabled' } |
|
429 | :class => 'icon-del disabled' } | |
430 | end |
|
430 | end | |
431 |
|
431 | |||
432 | def test_destroy_issue_with_no_time_entries |
|
432 | def test_destroy_issue_with_no_time_entries | |
433 | @request.session[:user_id] = 2 |
|
433 | @request.session[:user_id] = 2 | |
434 | post :destroy, :id => 3 |
|
434 | post :destroy, :id => 3 | |
435 | assert_redirected_to 'projects/ecookbook/issues' |
|
435 | assert_redirected_to 'projects/ecookbook/issues' | |
436 | assert_nil Issue.find_by_id(3) |
|
436 | assert_nil Issue.find_by_id(3) | |
437 | end |
|
437 | end | |
438 |
|
438 | |||
439 | def test_destroy_issues_with_time_entries |
|
439 | def test_destroy_issues_with_time_entries | |
440 | @request.session[:user_id] = 2 |
|
440 | @request.session[:user_id] = 2 | |
441 | post :destroy, :ids => [1, 3] |
|
441 | post :destroy, :ids => [1, 3] | |
442 | assert_response :success |
|
442 | assert_response :success | |
443 | assert_template 'destroy' |
|
443 | assert_template 'destroy' | |
444 | assert_not_nil assigns(:hours) |
|
444 | assert_not_nil assigns(:hours) | |
445 | assert Issue.find_by_id(1) && Issue.find_by_id(3) |
|
445 | assert Issue.find_by_id(1) && Issue.find_by_id(3) | |
446 | end |
|
446 | end | |
447 |
|
447 | |||
448 | def test_destroy_issues_and_destroy_time_entries |
|
448 | def test_destroy_issues_and_destroy_time_entries | |
449 | @request.session[:user_id] = 2 |
|
449 | @request.session[:user_id] = 2 | |
450 | post :destroy, :ids => [1, 3], :todo => 'destroy' |
|
450 | post :destroy, :ids => [1, 3], :todo => 'destroy' | |
451 | assert_redirected_to 'projects/ecookbook/issues' |
|
451 | assert_redirected_to 'projects/ecookbook/issues' | |
452 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
452 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) | |
453 | assert_nil TimeEntry.find_by_id([1, 2]) |
|
453 | assert_nil TimeEntry.find_by_id([1, 2]) | |
454 | end |
|
454 | end | |
455 |
|
455 | |||
456 | def test_destroy_issues_and_assign_time_entries_to_project |
|
456 | def test_destroy_issues_and_assign_time_entries_to_project | |
457 | @request.session[:user_id] = 2 |
|
457 | @request.session[:user_id] = 2 | |
458 | post :destroy, :ids => [1, 3], :todo => 'nullify' |
|
458 | post :destroy, :ids => [1, 3], :todo => 'nullify' | |
459 | assert_redirected_to 'projects/ecookbook/issues' |
|
459 | assert_redirected_to 'projects/ecookbook/issues' | |
460 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
460 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) | |
461 | assert_nil TimeEntry.find(1).issue_id |
|
461 | assert_nil TimeEntry.find(1).issue_id | |
462 | assert_nil TimeEntry.find(2).issue_id |
|
462 | assert_nil TimeEntry.find(2).issue_id | |
463 | end |
|
463 | end | |
464 |
|
464 | |||
465 | def test_destroy_issues_and_reassign_time_entries_to_another_issue |
|
465 | def test_destroy_issues_and_reassign_time_entries_to_another_issue | |
466 | @request.session[:user_id] = 2 |
|
466 | @request.session[:user_id] = 2 | |
467 | post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2 |
|
467 | post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2 | |
468 | assert_redirected_to 'projects/ecookbook/issues' |
|
468 | assert_redirected_to 'projects/ecookbook/issues' | |
469 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
469 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) | |
470 | assert_equal 2, TimeEntry.find(1).issue_id |
|
470 | assert_equal 2, TimeEntry.find(1).issue_id | |
471 | assert_equal 2, TimeEntry.find(2).issue_id |
|
471 | assert_equal 2, TimeEntry.find(2).issue_id | |
472 | end |
|
472 | end | |
473 |
|
473 | |||
474 | def test_destroy_attachment |
|
474 | def test_destroy_attachment | |
475 | issue = Issue.find(3) |
|
475 | issue = Issue.find(3) | |
476 | a = issue.attachments.size |
|
476 | a = issue.attachments.size | |
477 | @request.session[:user_id] = 2 |
|
477 | @request.session[:user_id] = 2 | |
478 | post :destroy_attachment, :id => 3, :attachment_id => 1 |
|
478 | post :destroy_attachment, :id => 3, :attachment_id => 1 | |
479 | assert_redirected_to 'issues/show/3' |
|
479 | assert_redirected_to 'issues/show/3' | |
480 | assert_nil Attachment.find_by_id(1) |
|
480 | assert_nil Attachment.find_by_id(1) | |
481 | issue.reload |
|
481 | issue.reload | |
482 | assert_equal((a-1), issue.attachments.size) |
|
482 | assert_equal((a-1), issue.attachments.size) | |
483 | j = issue.journals.find(:first, :order => 'created_on DESC') |
|
483 | j = issue.journals.find(:first, :order => 'created_on DESC') | |
484 | assert_equal 'attachment', j.details.first.property |
|
484 | assert_equal 'attachment', j.details.first.property | |
485 | end |
|
485 | end | |
486 | end |
|
486 | end |
@@ -1,71 +1,71 | |||||
1 | require "#{File.dirname(__FILE__)}/../test_helper" |
|
1 | require "#{File.dirname(__FILE__)}/../test_helper" | |
2 |
|
2 | |||
3 | class IssuesTest < ActionController::IntegrationTest |
|
3 | class IssuesTest < ActionController::IntegrationTest | |
4 | fixtures :projects, |
|
4 | fixtures :projects, | |
5 | :users, |
|
5 | :users, | |
6 | :trackers, |
|
6 | :trackers, | |
7 | :projects_trackers, |
|
7 | :projects_trackers, | |
8 | :issue_statuses, |
|
8 | :issue_statuses, | |
9 | :issues, |
|
9 | :issues, | |
10 | :enumerations, |
|
10 | :enumerations, | |
11 | :custom_fields, |
|
11 | :custom_fields, | |
12 | :custom_values, |
|
12 | :custom_values, | |
13 | :custom_fields_trackers |
|
13 | :custom_fields_trackers | |
14 |
|
14 | |||
15 | # create an issue |
|
15 | # create an issue | |
16 | def test_add_issue |
|
16 | def test_add_issue | |
17 | log_user('jsmith', 'jsmith') |
|
17 | log_user('jsmith', 'jsmith') | |
18 | get 'projects/1/issues/new', :tracker_id => '1' |
|
18 | get 'projects/1/issues/new', :tracker_id => '1' | |
19 | assert_response :success |
|
19 | assert_response :success | |
20 | assert_template 'issues/new' |
|
20 | assert_template 'issues/new' | |
21 |
|
21 | |||
22 | post 'projects/1/issues/new', :tracker_id => "1", |
|
22 | post 'projects/1/issues/new', :tracker_id => "1", | |
23 | :issue => { :start_date => "2006-12-26", |
|
23 | :issue => { :start_date => "2006-12-26", | |
24 | :priority_id => "3", |
|
24 | :priority_id => "3", | |
25 | :subject => "new test issue", |
|
25 | :subject => "new test issue", | |
26 | :category_id => "", |
|
26 | :category_id => "", | |
27 | :description => "new issue", |
|
27 | :description => "new issue", | |
28 | :done_ratio => "0", |
|
28 | :done_ratio => "0", | |
29 | :due_date => "", |
|
29 | :due_date => "", | |
30 | :assigned_to_id => "" }, |
|
30 | :assigned_to_id => "" }, | |
31 | :custom_fields => {'2' => 'Value for field 2'} |
|
31 | :custom_fields => {'2' => 'Value for field 2'} | |
32 | # find created issue |
|
32 | # find created issue | |
33 | issue = Issue.find_by_subject("new test issue") |
|
33 | issue = Issue.find_by_subject("new test issue") | |
34 | assert_kind_of Issue, issue |
|
34 | assert_kind_of Issue, issue | |
35 |
|
35 | |||
36 | # check redirection |
|
36 | # check redirection | |
37 |
assert_redirected_to " |
|
37 | assert_redirected_to "issues/show" | |
38 | follow_redirect! |
|
38 | follow_redirect! | |
39 |
assert assigns(:issue |
|
39 | assert_equal issue, assigns(:issue) | |
40 |
|
40 | |||
41 | # check issue attributes |
|
41 | # check issue attributes | |
42 | assert_equal 'jsmith', issue.author.login |
|
42 | assert_equal 'jsmith', issue.author.login | |
43 | assert_equal 1, issue.project.id |
|
43 | assert_equal 1, issue.project.id | |
44 | assert_equal 1, issue.status.id |
|
44 | assert_equal 1, issue.status.id | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | # add then remove 2 attachments to an issue |
|
47 | # add then remove 2 attachments to an issue | |
48 | def test_issue_attachements |
|
48 | def test_issue_attachements | |
49 | log_user('jsmith', 'jsmith') |
|
49 | log_user('jsmith', 'jsmith') | |
50 |
|
50 | |||
51 | post 'issues/edit/1', |
|
51 | post 'issues/edit/1', | |
52 | :notes => 'Some notes', |
|
52 | :notes => 'Some notes', | |
53 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} |
|
53 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} | |
54 | assert_redirected_to "issues/show/1" |
|
54 | assert_redirected_to "issues/show/1" | |
55 |
|
55 | |||
56 | # make sure attachment was saved |
|
56 | # make sure attachment was saved | |
57 | attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") |
|
57 | attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") | |
58 | assert_kind_of Attachment, attachment |
|
58 | assert_kind_of Attachment, attachment | |
59 | assert_equal Issue.find(1), attachment.container |
|
59 | assert_equal Issue.find(1), attachment.container | |
60 | assert_equal 'This is an attachment', attachment.description |
|
60 | assert_equal 'This is an attachment', attachment.description | |
61 | # verify the size of the attachment stored in db |
|
61 | # verify the size of the attachment stored in db | |
62 | #assert_equal file_data_1.length, attachment.filesize |
|
62 | #assert_equal file_data_1.length, attachment.filesize | |
63 | # verify that the attachment was written to disk |
|
63 | # verify that the attachment was written to disk | |
64 | assert File.exist?(attachment.diskfile) |
|
64 | assert File.exist?(attachment.diskfile) | |
65 |
|
65 | |||
66 | # remove the attachments |
|
66 | # remove the attachments | |
67 | Issue.find(1).attachments.each(&:destroy) |
|
67 | Issue.find(1).attachments.each(&:destroy) | |
68 | assert_equal 0, Issue.find(1).attachments.length |
|
68 | assert_equal 0, Issue.find(1).attachments.length | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | end |
|
71 | end |
General Comments 0
You need to be logged in to leave comments.
Login now