@@ -1,79 +1,79 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'attachments_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class AttachmentsController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | class AttachmentsControllerTest < Test::Unit::TestCase |
|
26 | fixtures :users, :projects, :issues, :attachments | |
|
26 | fixtures :users, :projects, :roles, :members, :enabled_modules, :issues, :attachments | |
|
27 | 27 | |
|
28 | 28 | def setup |
|
29 | 29 | @controller = AttachmentsController.new |
|
30 | 30 | @request = ActionController::TestRequest.new |
|
31 | 31 | @response = ActionController::TestResponse.new |
|
32 | 32 | Attachment.storage_path = "#{RAILS_ROOT}/test/fixtures/files" |
|
33 | 33 | User.current = nil |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def test_routing |
|
37 | 37 | assert_routing('/attachments/1', :controller => 'attachments', :action => 'show', :id => '1') |
|
38 | 38 | assert_routing('/attachments/1/filename.ext', :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext') |
|
39 | 39 | assert_routing('/attachments/download/1', :controller => 'attachments', :action => 'download', :id => '1') |
|
40 | 40 | assert_routing('/attachments/download/1/filename.ext', :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext') |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def test_recognizes |
|
44 | 44 | assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/1') |
|
45 | 45 | assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/show/1') |
|
46 | 46 | assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'}, '/attachments/1/filename.ext') |
|
47 | 47 | assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1'}, '/attachments/download/1') |
|
48 | 48 | assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'},'/attachments/download/1/filename.ext') |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def test_show_diff |
|
52 | 52 | get :show, :id => 5 |
|
53 | 53 | assert_response :success |
|
54 | 54 | assert_template 'diff' |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | def test_show_text_file |
|
58 | 58 | get :show, :id => 4 |
|
59 | 59 | assert_response :success |
|
60 | 60 | assert_template 'file' |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | def test_show_other |
|
64 | 64 | get :show, :id => 6 |
|
65 | 65 | assert_response :success |
|
66 | 66 | assert_equal 'application/octet-stream', @response.content_type |
|
67 | 67 | end |
|
68 | 68 | |
|
69 | 69 | def test_download_text_file |
|
70 | 70 | get :download, :id => 4 |
|
71 | 71 | assert_response :success |
|
72 | 72 | assert_equal 'application/x-ruby', @response.content_type |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | def test_anonymous_on_private_private |
|
76 | 76 | get :download, :id => 7 |
|
77 | 77 | assert_redirected_to 'account/login' |
|
78 | 78 | end |
|
79 | 79 | end |
@@ -1,689 +1,690 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'issues_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class IssuesController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class IssuesControllerTest < Test::Unit::TestCase |
|
25 | 25 | fixtures :projects, |
|
26 | 26 | :users, |
|
27 | 27 | :roles, |
|
28 | 28 | :members, |
|
29 | 29 | :issues, |
|
30 | 30 | :issue_statuses, |
|
31 | :versions, | |
|
31 | 32 | :trackers, |
|
32 | 33 | :projects_trackers, |
|
33 | 34 | :issue_categories, |
|
34 | 35 | :enabled_modules, |
|
35 | 36 | :enumerations, |
|
36 | 37 | :attachments, |
|
37 | 38 | :workflows, |
|
38 | 39 | :custom_fields, |
|
39 | 40 | :custom_values, |
|
40 | 41 | :custom_fields_trackers, |
|
41 | 42 | :time_entries, |
|
42 | 43 | :journals, |
|
43 | 44 | :journal_details |
|
44 | 45 | |
|
45 | 46 | def setup |
|
46 | 47 | @controller = IssuesController.new |
|
47 | 48 | @request = ActionController::TestRequest.new |
|
48 | 49 | @response = ActionController::TestResponse.new |
|
49 | 50 | User.current = nil |
|
50 | 51 | end |
|
51 | 52 | |
|
52 | 53 | def test_index |
|
53 | 54 | get :index |
|
54 | 55 | assert_response :success |
|
55 | 56 | assert_template 'index.rhtml' |
|
56 | 57 | assert_not_nil assigns(:issues) |
|
57 | 58 | assert_nil assigns(:project) |
|
58 | 59 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
59 | 60 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
60 | 61 | # private projects hidden |
|
61 | 62 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
62 | 63 | assert_no_tag :tag => 'a', :content => /Issue on project 2/ |
|
63 | 64 | end |
|
64 | 65 | |
|
65 | 66 | def test_index_with_project |
|
66 | 67 | Setting.display_subprojects_issues = 0 |
|
67 | 68 | get :index, :project_id => 1 |
|
68 | 69 | assert_response :success |
|
69 | 70 | assert_template 'index.rhtml' |
|
70 | 71 | assert_not_nil assigns(:issues) |
|
71 | 72 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
72 | 73 | assert_no_tag :tag => 'a', :content => /Subproject issue/ |
|
73 | 74 | end |
|
74 | 75 | |
|
75 | 76 | def test_index_with_project_and_subprojects |
|
76 | 77 | Setting.display_subprojects_issues = 1 |
|
77 | 78 | get :index, :project_id => 1 |
|
78 | 79 | assert_response :success |
|
79 | 80 | assert_template 'index.rhtml' |
|
80 | 81 | assert_not_nil assigns(:issues) |
|
81 | 82 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
82 | 83 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
83 | 84 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
84 | 85 | end |
|
85 | 86 | |
|
86 | 87 | def test_index_with_project_and_subprojects_should_show_private_subprojects |
|
87 | 88 | @request.session[:user_id] = 2 |
|
88 | 89 | Setting.display_subprojects_issues = 1 |
|
89 | 90 | get :index, :project_id => 1 |
|
90 | 91 | assert_response :success |
|
91 | 92 | assert_template 'index.rhtml' |
|
92 | 93 | assert_not_nil assigns(:issues) |
|
93 | 94 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
94 | 95 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
95 | 96 | assert_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
96 | 97 | end |
|
97 | 98 | |
|
98 | 99 | def test_index_with_project_and_filter |
|
99 | 100 | get :index, :project_id => 1, :set_filter => 1 |
|
100 | 101 | assert_response :success |
|
101 | 102 | assert_template 'index.rhtml' |
|
102 | 103 | assert_not_nil assigns(:issues) |
|
103 | 104 | end |
|
104 | 105 | |
|
105 | 106 | def test_index_csv_with_project |
|
106 | 107 | get :index, :format => 'csv' |
|
107 | 108 | assert_response :success |
|
108 | 109 | assert_not_nil assigns(:issues) |
|
109 | 110 | assert_equal 'text/csv', @response.content_type |
|
110 | 111 | |
|
111 | 112 | get :index, :project_id => 1, :format => 'csv' |
|
112 | 113 | assert_response :success |
|
113 | 114 | assert_not_nil assigns(:issues) |
|
114 | 115 | assert_equal 'text/csv', @response.content_type |
|
115 | 116 | end |
|
116 | 117 | |
|
117 | 118 | def test_index_pdf |
|
118 | 119 | get :index, :format => 'pdf' |
|
119 | 120 | assert_response :success |
|
120 | 121 | assert_not_nil assigns(:issues) |
|
121 | 122 | assert_equal 'application/pdf', @response.content_type |
|
122 | 123 | |
|
123 | 124 | get :index, :project_id => 1, :format => 'pdf' |
|
124 | 125 | assert_response :success |
|
125 | 126 | assert_not_nil assigns(:issues) |
|
126 | 127 | assert_equal 'application/pdf', @response.content_type |
|
127 | 128 | end |
|
128 | 129 | |
|
129 | 130 | def test_gantt |
|
130 | 131 | get :gantt, :project_id => 1 |
|
131 | 132 | assert_response :success |
|
132 | 133 | assert_template 'gantt.rhtml' |
|
133 | 134 | assert_not_nil assigns(:gantt) |
|
134 | 135 | events = assigns(:gantt).events |
|
135 | 136 | assert_not_nil events |
|
136 | 137 | # Issue with start and due dates |
|
137 | 138 | i = Issue.find(1) |
|
138 | 139 | assert_not_nil i.due_date |
|
139 | 140 | assert events.include?(Issue.find(1)) |
|
140 | 141 | # Issue with without due date but targeted to a version with date |
|
141 | 142 | i = Issue.find(2) |
|
142 | 143 | assert_nil i.due_date |
|
143 | 144 | assert events.include?(i) |
|
144 | 145 | end |
|
145 | 146 | |
|
146 | 147 | def test_gantt_export_to_pdf |
|
147 | 148 | get :gantt, :project_id => 1, :format => 'pdf' |
|
148 | 149 | assert_response :success |
|
149 | 150 | assert_template 'gantt.rfpdf' |
|
150 | 151 | assert_equal 'application/pdf', @response.content_type |
|
151 | 152 | assert_not_nil assigns(:gantt) |
|
152 | 153 | end |
|
153 | 154 | |
|
154 | 155 | if Object.const_defined?(:Magick) |
|
155 | 156 | def test_gantt_image |
|
156 | 157 | get :gantt, :project_id => 1, :format => 'png' |
|
157 | 158 | assert_response :success |
|
158 | 159 | assert_equal 'image/png', @response.content_type |
|
159 | 160 | end |
|
160 | 161 | else |
|
161 | 162 | puts "RMagick not installed. Skipping tests !!!" |
|
162 | 163 | end |
|
163 | 164 | |
|
164 | 165 | def test_calendar |
|
165 | 166 | get :calendar, :project_id => 1 |
|
166 | 167 | assert_response :success |
|
167 | 168 | assert_template 'calendar' |
|
168 | 169 | assert_not_nil assigns(:calendar) |
|
169 | 170 | end |
|
170 | 171 | |
|
171 | 172 | def test_changes |
|
172 | 173 | get :changes, :project_id => 1 |
|
173 | 174 | assert_response :success |
|
174 | 175 | assert_not_nil assigns(:journals) |
|
175 | 176 | assert_equal 'application/atom+xml', @response.content_type |
|
176 | 177 | end |
|
177 | 178 | |
|
178 | 179 | def test_show_by_anonymous |
|
179 | 180 | get :show, :id => 1 |
|
180 | 181 | assert_response :success |
|
181 | 182 | assert_template 'show.rhtml' |
|
182 | 183 | assert_not_nil assigns(:issue) |
|
183 | 184 | assert_equal Issue.find(1), assigns(:issue) |
|
184 | 185 | |
|
185 | 186 | # anonymous role is allowed to add a note |
|
186 | 187 | assert_tag :tag => 'form', |
|
187 | 188 | :descendant => { :tag => 'fieldset', |
|
188 | 189 | :child => { :tag => 'legend', |
|
189 | 190 | :content => /Notes/ } } |
|
190 | 191 | end |
|
191 | 192 | |
|
192 | 193 | def test_show_by_manager |
|
193 | 194 | @request.session[:user_id] = 2 |
|
194 | 195 | get :show, :id => 1 |
|
195 | 196 | assert_response :success |
|
196 | 197 | |
|
197 | 198 | assert_tag :tag => 'form', |
|
198 | 199 | :descendant => { :tag => 'fieldset', |
|
199 | 200 | :child => { :tag => 'legend', |
|
200 | 201 | :content => /Change properties/ } }, |
|
201 | 202 | :descendant => { :tag => 'fieldset', |
|
202 | 203 | :child => { :tag => 'legend', |
|
203 | 204 | :content => /Log time/ } }, |
|
204 | 205 | :descendant => { :tag => 'fieldset', |
|
205 | 206 | :child => { :tag => 'legend', |
|
206 | 207 | :content => /Notes/ } } |
|
207 | 208 | end |
|
208 | 209 | |
|
209 | 210 | def test_get_new |
|
210 | 211 | @request.session[:user_id] = 2 |
|
211 | 212 | get :new, :project_id => 1, :tracker_id => 1 |
|
212 | 213 | assert_response :success |
|
213 | 214 | assert_template 'new' |
|
214 | 215 | |
|
215 | 216 | assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]', |
|
216 | 217 | :value => 'Default string' } |
|
217 | 218 | end |
|
218 | 219 | |
|
219 | 220 | def test_get_new_without_tracker_id |
|
220 | 221 | @request.session[:user_id] = 2 |
|
221 | 222 | get :new, :project_id => 1 |
|
222 | 223 | assert_response :success |
|
223 | 224 | assert_template 'new' |
|
224 | 225 | |
|
225 | 226 | issue = assigns(:issue) |
|
226 | 227 | assert_not_nil issue |
|
227 | 228 | assert_equal Project.find(1).trackers.first, issue.tracker |
|
228 | 229 | end |
|
229 | 230 | |
|
230 | 231 | def test_update_new_form |
|
231 | 232 | @request.session[:user_id] = 2 |
|
232 | 233 | xhr :post, :new, :project_id => 1, |
|
233 | 234 | :issue => {:tracker_id => 2, |
|
234 | 235 | :subject => 'This is the test_new issue', |
|
235 | 236 | :description => 'This is the description', |
|
236 | 237 | :priority_id => 5} |
|
237 | 238 | assert_response :success |
|
238 | 239 | assert_template 'new' |
|
239 | 240 | end |
|
240 | 241 | |
|
241 | 242 | def test_post_new |
|
242 | 243 | @request.session[:user_id] = 2 |
|
243 | 244 | post :new, :project_id => 1, |
|
244 | 245 | :issue => {:tracker_id => 3, |
|
245 | 246 | :subject => 'This is the test_new issue', |
|
246 | 247 | :description => 'This is the description', |
|
247 | 248 | :priority_id => 5, |
|
248 | 249 | :estimated_hours => '', |
|
249 | 250 | :custom_field_values => {'2' => 'Value for field 2'}} |
|
250 | 251 | assert_redirected_to 'issues/show' |
|
251 | 252 | |
|
252 | 253 | issue = Issue.find_by_subject('This is the test_new issue') |
|
253 | 254 | assert_not_nil issue |
|
254 | 255 | assert_equal 2, issue.author_id |
|
255 | 256 | assert_equal 3, issue.tracker_id |
|
256 | 257 | assert_nil issue.estimated_hours |
|
257 | 258 | v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2}) |
|
258 | 259 | assert_not_nil v |
|
259 | 260 | assert_equal 'Value for field 2', v.value |
|
260 | 261 | end |
|
261 | 262 | |
|
262 | 263 | def test_post_new_without_custom_fields_param |
|
263 | 264 | @request.session[:user_id] = 2 |
|
264 | 265 | post :new, :project_id => 1, |
|
265 | 266 | :issue => {:tracker_id => 1, |
|
266 | 267 | :subject => 'This is the test_new issue', |
|
267 | 268 | :description => 'This is the description', |
|
268 | 269 | :priority_id => 5} |
|
269 | 270 | assert_redirected_to 'issues/show' |
|
270 | 271 | end |
|
271 | 272 | |
|
272 | 273 | def test_post_new_with_required_custom_field_and_without_custom_fields_param |
|
273 | 274 | field = IssueCustomField.find_by_name('Database') |
|
274 | 275 | field.update_attribute(:is_required, true) |
|
275 | 276 | |
|
276 | 277 | @request.session[:user_id] = 2 |
|
277 | 278 | post :new, :project_id => 1, |
|
278 | 279 | :issue => {:tracker_id => 1, |
|
279 | 280 | :subject => 'This is the test_new issue', |
|
280 | 281 | :description => 'This is the description', |
|
281 | 282 | :priority_id => 5} |
|
282 | 283 | assert_response :success |
|
283 | 284 | assert_template 'new' |
|
284 | 285 | issue = assigns(:issue) |
|
285 | 286 | assert_not_nil issue |
|
286 | 287 | assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values) |
|
287 | 288 | end |
|
288 | 289 | |
|
289 | 290 | def test_post_should_preserve_fields_values_on_validation_failure |
|
290 | 291 | @request.session[:user_id] = 2 |
|
291 | 292 | post :new, :project_id => 1, |
|
292 | 293 | :issue => {:tracker_id => 1, |
|
293 | 294 | :subject => 'This is the test_new issue', |
|
294 | 295 | # empty description |
|
295 | 296 | :description => '', |
|
296 | 297 | :priority_id => 6, |
|
297 | 298 | :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}} |
|
298 | 299 | assert_response :success |
|
299 | 300 | assert_template 'new' |
|
300 | 301 | |
|
301 | 302 | assert_tag :input, :attributes => { :name => 'issue[subject]', |
|
302 | 303 | :value => 'This is the test_new issue' } |
|
303 | 304 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, |
|
304 | 305 | :child => { :tag => 'option', :attributes => { :selected => 'selected', |
|
305 | 306 | :value => '6' }, |
|
306 | 307 | :content => 'High' } |
|
307 | 308 | # Custom fields |
|
308 | 309 | assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' }, |
|
309 | 310 | :child => { :tag => 'option', :attributes => { :selected => 'selected', |
|
310 | 311 | :value => 'Oracle' }, |
|
311 | 312 | :content => 'Oracle' } |
|
312 | 313 | assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]', |
|
313 | 314 | :value => 'Value for field 2'} |
|
314 | 315 | end |
|
315 | 316 | |
|
316 | 317 | def test_copy_issue |
|
317 | 318 | @request.session[:user_id] = 2 |
|
318 | 319 | get :new, :project_id => 1, :copy_from => 1 |
|
319 | 320 | assert_template 'new' |
|
320 | 321 | assert_not_nil assigns(:issue) |
|
321 | 322 | orig = Issue.find(1) |
|
322 | 323 | assert_equal orig.subject, assigns(:issue).subject |
|
323 | 324 | end |
|
324 | 325 | |
|
325 | 326 | def test_get_edit |
|
326 | 327 | @request.session[:user_id] = 2 |
|
327 | 328 | get :edit, :id => 1 |
|
328 | 329 | assert_response :success |
|
329 | 330 | assert_template 'edit' |
|
330 | 331 | assert_not_nil assigns(:issue) |
|
331 | 332 | assert_equal Issue.find(1), assigns(:issue) |
|
332 | 333 | end |
|
333 | 334 | |
|
334 | 335 | def test_get_edit_with_params |
|
335 | 336 | @request.session[:user_id] = 2 |
|
336 | 337 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 } |
|
337 | 338 | assert_response :success |
|
338 | 339 | assert_template 'edit' |
|
339 | 340 | |
|
340 | 341 | issue = assigns(:issue) |
|
341 | 342 | assert_not_nil issue |
|
342 | 343 | |
|
343 | 344 | assert_equal 5, issue.status_id |
|
344 | 345 | assert_tag :select, :attributes => { :name => 'issue[status_id]' }, |
|
345 | 346 | :child => { :tag => 'option', |
|
346 | 347 | :content => 'Closed', |
|
347 | 348 | :attributes => { :selected => 'selected' } } |
|
348 | 349 | |
|
349 | 350 | assert_equal 7, issue.priority_id |
|
350 | 351 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, |
|
351 | 352 | :child => { :tag => 'option', |
|
352 | 353 | :content => 'Urgent', |
|
353 | 354 | :attributes => { :selected => 'selected' } } |
|
354 | 355 | end |
|
355 | 356 | |
|
356 | 357 | def test_reply_to_issue |
|
357 | 358 | @request.session[:user_id] = 2 |
|
358 | 359 | get :reply, :id => 1 |
|
359 | 360 | assert_response :success |
|
360 | 361 | assert_select_rjs :show, "update" |
|
361 | 362 | end |
|
362 | 363 | |
|
363 | 364 | def test_reply_to_note |
|
364 | 365 | @request.session[:user_id] = 2 |
|
365 | 366 | get :reply, :id => 1, :journal_id => 2 |
|
366 | 367 | assert_response :success |
|
367 | 368 | assert_select_rjs :show, "update" |
|
368 | 369 | end |
|
369 | 370 | |
|
370 | 371 | def test_post_edit_without_custom_fields_param |
|
371 | 372 | @request.session[:user_id] = 2 |
|
372 | 373 | ActionMailer::Base.deliveries.clear |
|
373 | 374 | |
|
374 | 375 | issue = Issue.find(1) |
|
375 | 376 | assert_equal '125', issue.custom_value_for(2).value |
|
376 | 377 | old_subject = issue.subject |
|
377 | 378 | new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' |
|
378 | 379 | |
|
379 | 380 | assert_difference('Journal.count') do |
|
380 | 381 | assert_difference('JournalDetail.count', 2) do |
|
381 | 382 | post :edit, :id => 1, :issue => {:subject => new_subject, |
|
382 | 383 | :priority_id => '6', |
|
383 | 384 | :category_id => '1' # no change |
|
384 | 385 | } |
|
385 | 386 | end |
|
386 | 387 | end |
|
387 | 388 | assert_redirected_to 'issues/show/1' |
|
388 | 389 | issue.reload |
|
389 | 390 | assert_equal new_subject, issue.subject |
|
390 | 391 | # Make sure custom fields were not cleared |
|
391 | 392 | assert_equal '125', issue.custom_value_for(2).value |
|
392 | 393 | |
|
393 | 394 | mail = ActionMailer::Base.deliveries.last |
|
394 | 395 | assert_kind_of TMail::Mail, mail |
|
395 | 396 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
396 | 397 | assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}") |
|
397 | 398 | end |
|
398 | 399 | |
|
399 | 400 | def test_post_edit_with_custom_field_change |
|
400 | 401 | @request.session[:user_id] = 2 |
|
401 | 402 | issue = Issue.find(1) |
|
402 | 403 | assert_equal '125', issue.custom_value_for(2).value |
|
403 | 404 | |
|
404 | 405 | assert_difference('Journal.count') do |
|
405 | 406 | assert_difference('JournalDetail.count', 3) do |
|
406 | 407 | post :edit, :id => 1, :issue => {:subject => 'Custom field change', |
|
407 | 408 | :priority_id => '6', |
|
408 | 409 | :category_id => '1', # no change |
|
409 | 410 | :custom_field_values => { '2' => 'New custom value' } |
|
410 | 411 | } |
|
411 | 412 | end |
|
412 | 413 | end |
|
413 | 414 | assert_redirected_to 'issues/show/1' |
|
414 | 415 | issue.reload |
|
415 | 416 | assert_equal 'New custom value', issue.custom_value_for(2).value |
|
416 | 417 | |
|
417 | 418 | mail = ActionMailer::Base.deliveries.last |
|
418 | 419 | assert_kind_of TMail::Mail, mail |
|
419 | 420 | assert mail.body.include?("Searchable field changed from 125 to New custom value") |
|
420 | 421 | end |
|
421 | 422 | |
|
422 | 423 | def test_post_edit_with_status_and_assignee_change |
|
423 | 424 | issue = Issue.find(1) |
|
424 | 425 | assert_equal 1, issue.status_id |
|
425 | 426 | @request.session[:user_id] = 2 |
|
426 | 427 | assert_difference('TimeEntry.count', 0) do |
|
427 | 428 | post :edit, |
|
428 | 429 | :id => 1, |
|
429 | 430 | :issue => { :status_id => 2, :assigned_to_id => 3 }, |
|
430 | 431 | :notes => 'Assigned to dlopper', |
|
431 | 432 | :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } |
|
432 | 433 | end |
|
433 | 434 | assert_redirected_to 'issues/show/1' |
|
434 | 435 | issue.reload |
|
435 | 436 | assert_equal 2, issue.status_id |
|
436 | 437 | j = issue.journals.find(:first, :order => 'id DESC') |
|
437 | 438 | assert_equal 'Assigned to dlopper', j.notes |
|
438 | 439 | assert_equal 2, j.details.size |
|
439 | 440 | |
|
440 | 441 | mail = ActionMailer::Base.deliveries.last |
|
441 | 442 | assert mail.body.include?("Status changed from New to Assigned") |
|
442 | 443 | end |
|
443 | 444 | |
|
444 | 445 | def test_post_edit_with_note_only |
|
445 | 446 | notes = 'Note added by IssuesControllerTest#test_update_with_note_only' |
|
446 | 447 | # anonymous user |
|
447 | 448 | post :edit, |
|
448 | 449 | :id => 1, |
|
449 | 450 | :notes => notes |
|
450 | 451 | assert_redirected_to 'issues/show/1' |
|
451 | 452 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
452 | 453 | assert_equal notes, j.notes |
|
453 | 454 | assert_equal 0, j.details.size |
|
454 | 455 | assert_equal User.anonymous, j.user |
|
455 | 456 | |
|
456 | 457 | mail = ActionMailer::Base.deliveries.last |
|
457 | 458 | assert mail.body.include?(notes) |
|
458 | 459 | end |
|
459 | 460 | |
|
460 | 461 | def test_post_edit_with_note_and_spent_time |
|
461 | 462 | @request.session[:user_id] = 2 |
|
462 | 463 | spent_hours_before = Issue.find(1).spent_hours |
|
463 | 464 | assert_difference('TimeEntry.count') do |
|
464 | 465 | post :edit, |
|
465 | 466 | :id => 1, |
|
466 | 467 | :notes => '2.5 hours added', |
|
467 | 468 | :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } |
|
468 | 469 | end |
|
469 | 470 | assert_redirected_to 'issues/show/1' |
|
470 | 471 | |
|
471 | 472 | issue = Issue.find(1) |
|
472 | 473 | |
|
473 | 474 | j = issue.journals.find(:first, :order => 'id DESC') |
|
474 | 475 | assert_equal '2.5 hours added', j.notes |
|
475 | 476 | assert_equal 0, j.details.size |
|
476 | 477 | |
|
477 | 478 | t = issue.time_entries.find(:first, :order => 'id DESC') |
|
478 | 479 | assert_not_nil t |
|
479 | 480 | assert_equal 2.5, t.hours |
|
480 | 481 | assert_equal spent_hours_before + 2.5, issue.spent_hours |
|
481 | 482 | end |
|
482 | 483 | |
|
483 | 484 | def test_post_edit_with_attachment_only |
|
484 | 485 | set_tmp_attachments_directory |
|
485 | 486 | |
|
486 | 487 | # anonymous user |
|
487 | 488 | post :edit, |
|
488 | 489 | :id => 1, |
|
489 | 490 | :notes => '', |
|
490 | 491 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}} |
|
491 | 492 | assert_redirected_to 'issues/show/1' |
|
492 | 493 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
493 | 494 | assert j.notes.blank? |
|
494 | 495 | assert_equal 1, j.details.size |
|
495 | 496 | assert_equal 'testfile.txt', j.details.first.value |
|
496 | 497 | assert_equal User.anonymous, j.user |
|
497 | 498 | |
|
498 | 499 | mail = ActionMailer::Base.deliveries.last |
|
499 | 500 | assert mail.body.include?('testfile.txt') |
|
500 | 501 | end |
|
501 | 502 | |
|
502 | 503 | def test_post_edit_with_no_change |
|
503 | 504 | issue = Issue.find(1) |
|
504 | 505 | issue.journals.clear |
|
505 | 506 | ActionMailer::Base.deliveries.clear |
|
506 | 507 | |
|
507 | 508 | post :edit, |
|
508 | 509 | :id => 1, |
|
509 | 510 | :notes => '' |
|
510 | 511 | assert_redirected_to 'issues/show/1' |
|
511 | 512 | |
|
512 | 513 | issue.reload |
|
513 | 514 | assert issue.journals.empty? |
|
514 | 515 | # No email should be sent |
|
515 | 516 | assert ActionMailer::Base.deliveries.empty? |
|
516 | 517 | end |
|
517 | 518 | |
|
518 | 519 | def test_bulk_edit |
|
519 | 520 | @request.session[:user_id] = 2 |
|
520 | 521 | # update issues priority |
|
521 | 522 | post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' |
|
522 | 523 | assert_response 302 |
|
523 | 524 | # check that the issues were updated |
|
524 | 525 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
525 | 526 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes |
|
526 | 527 | end |
|
527 | 528 | |
|
528 | 529 | def test_bulk_unassign |
|
529 | 530 | assert_not_nil Issue.find(2).assigned_to |
|
530 | 531 | @request.session[:user_id] = 2 |
|
531 | 532 | # unassign issues |
|
532 | 533 | post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none' |
|
533 | 534 | assert_response 302 |
|
534 | 535 | # check that the issues were updated |
|
535 | 536 | assert_nil Issue.find(2).assigned_to |
|
536 | 537 | end |
|
537 | 538 | |
|
538 | 539 | def test_move_one_issue_to_another_project |
|
539 | 540 | @request.session[:user_id] = 1 |
|
540 | 541 | post :move, :id => 1, :new_project_id => 2 |
|
541 | 542 | assert_redirected_to 'projects/ecookbook/issues' |
|
542 | 543 | assert_equal 2, Issue.find(1).project_id |
|
543 | 544 | end |
|
544 | 545 | |
|
545 | 546 | def test_bulk_move_to_another_project |
|
546 | 547 | @request.session[:user_id] = 1 |
|
547 | 548 | post :move, :ids => [1, 2], :new_project_id => 2 |
|
548 | 549 | assert_redirected_to 'projects/ecookbook/issues' |
|
549 | 550 | # Issues moved to project 2 |
|
550 | 551 | assert_equal 2, Issue.find(1).project_id |
|
551 | 552 | assert_equal 2, Issue.find(2).project_id |
|
552 | 553 | # No tracker change |
|
553 | 554 | assert_equal 1, Issue.find(1).tracker_id |
|
554 | 555 | assert_equal 2, Issue.find(2).tracker_id |
|
555 | 556 | end |
|
556 | 557 | |
|
557 | 558 | def test_bulk_move_to_another_tracker |
|
558 | 559 | @request.session[:user_id] = 1 |
|
559 | 560 | post :move, :ids => [1, 2], :new_tracker_id => 2 |
|
560 | 561 | assert_redirected_to 'projects/ecookbook/issues' |
|
561 | 562 | assert_equal 2, Issue.find(1).tracker_id |
|
562 | 563 | assert_equal 2, Issue.find(2).tracker_id |
|
563 | 564 | end |
|
564 | 565 | |
|
565 | 566 | def test_context_menu_one_issue |
|
566 | 567 | @request.session[:user_id] = 2 |
|
567 | 568 | get :context_menu, :ids => [1] |
|
568 | 569 | assert_response :success |
|
569 | 570 | assert_template 'context_menu' |
|
570 | 571 | assert_tag :tag => 'a', :content => 'Edit', |
|
571 | 572 | :attributes => { :href => '/issues/edit/1', |
|
572 | 573 | :class => 'icon-edit' } |
|
573 | 574 | assert_tag :tag => 'a', :content => 'Closed', |
|
574 | 575 | :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5', |
|
575 | 576 | :class => '' } |
|
576 | 577 | assert_tag :tag => 'a', :content => 'Immediate', |
|
577 | 578 | :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&priority_id=8', |
|
578 | 579 | :class => '' } |
|
579 | 580 | assert_tag :tag => 'a', :content => 'Dave Lopper', |
|
580 | 581 | :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1', |
|
581 | 582 | :class => '' } |
|
582 | 583 | assert_tag :tag => 'a', :content => 'Copy', |
|
583 | 584 | :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1', |
|
584 | 585 | :class => 'icon-copy' } |
|
585 | 586 | assert_tag :tag => 'a', :content => 'Move', |
|
586 | 587 | :attributes => { :href => '/issues/move?ids%5B%5D=1', |
|
587 | 588 | :class => 'icon-move' } |
|
588 | 589 | assert_tag :tag => 'a', :content => 'Delete', |
|
589 | 590 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1', |
|
590 | 591 | :class => 'icon-del' } |
|
591 | 592 | end |
|
592 | 593 | |
|
593 | 594 | def test_context_menu_one_issue_by_anonymous |
|
594 | 595 | get :context_menu, :ids => [1] |
|
595 | 596 | assert_response :success |
|
596 | 597 | assert_template 'context_menu' |
|
597 | 598 | assert_tag :tag => 'a', :content => 'Delete', |
|
598 | 599 | :attributes => { :href => '#', |
|
599 | 600 | :class => 'icon-del disabled' } |
|
600 | 601 | end |
|
601 | 602 | |
|
602 | 603 | def test_context_menu_multiple_issues_of_same_project |
|
603 | 604 | @request.session[:user_id] = 2 |
|
604 | 605 | get :context_menu, :ids => [1, 2] |
|
605 | 606 | assert_response :success |
|
606 | 607 | assert_template 'context_menu' |
|
607 | 608 | assert_tag :tag => 'a', :content => 'Edit', |
|
608 | 609 | :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', |
|
609 | 610 | :class => 'icon-edit' } |
|
610 | 611 | assert_tag :tag => 'a', :content => 'Immediate', |
|
611 | 612 | :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&priority_id=8', |
|
612 | 613 | :class => '' } |
|
613 | 614 | assert_tag :tag => 'a', :content => 'Dave Lopper', |
|
614 | 615 | :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1&ids%5B%5D=2', |
|
615 | 616 | :class => '' } |
|
616 | 617 | assert_tag :tag => 'a', :content => 'Move', |
|
617 | 618 | :attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2', |
|
618 | 619 | :class => 'icon-move' } |
|
619 | 620 | assert_tag :tag => 'a', :content => 'Delete', |
|
620 | 621 | :attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2', |
|
621 | 622 | :class => 'icon-del' } |
|
622 | 623 | end |
|
623 | 624 | |
|
624 | 625 | def test_context_menu_multiple_issues_of_different_project |
|
625 | 626 | @request.session[:user_id] = 2 |
|
626 | 627 | get :context_menu, :ids => [1, 2, 4] |
|
627 | 628 | assert_response :success |
|
628 | 629 | assert_template 'context_menu' |
|
629 | 630 | assert_tag :tag => 'a', :content => 'Delete', |
|
630 | 631 | :attributes => { :href => '#', |
|
631 | 632 | :class => 'icon-del disabled' } |
|
632 | 633 | end |
|
633 | 634 | |
|
634 | 635 | def test_destroy_issue_with_no_time_entries |
|
635 | 636 | assert_nil TimeEntry.find_by_issue_id(2) |
|
636 | 637 | @request.session[:user_id] = 2 |
|
637 | 638 | post :destroy, :id => 2 |
|
638 | 639 | assert_redirected_to 'projects/ecookbook/issues' |
|
639 | 640 | assert_nil Issue.find_by_id(2) |
|
640 | 641 | end |
|
641 | 642 | |
|
642 | 643 | def test_destroy_issues_with_time_entries |
|
643 | 644 | @request.session[:user_id] = 2 |
|
644 | 645 | post :destroy, :ids => [1, 3] |
|
645 | 646 | assert_response :success |
|
646 | 647 | assert_template 'destroy' |
|
647 | 648 | assert_not_nil assigns(:hours) |
|
648 | 649 | assert Issue.find_by_id(1) && Issue.find_by_id(3) |
|
649 | 650 | end |
|
650 | 651 | |
|
651 | 652 | def test_destroy_issues_and_destroy_time_entries |
|
652 | 653 | @request.session[:user_id] = 2 |
|
653 | 654 | post :destroy, :ids => [1, 3], :todo => 'destroy' |
|
654 | 655 | assert_redirected_to 'projects/ecookbook/issues' |
|
655 | 656 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
656 | 657 | assert_nil TimeEntry.find_by_id([1, 2]) |
|
657 | 658 | end |
|
658 | 659 | |
|
659 | 660 | def test_destroy_issues_and_assign_time_entries_to_project |
|
660 | 661 | @request.session[:user_id] = 2 |
|
661 | 662 | post :destroy, :ids => [1, 3], :todo => 'nullify' |
|
662 | 663 | assert_redirected_to 'projects/ecookbook/issues' |
|
663 | 664 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
664 | 665 | assert_nil TimeEntry.find(1).issue_id |
|
665 | 666 | assert_nil TimeEntry.find(2).issue_id |
|
666 | 667 | end |
|
667 | 668 | |
|
668 | 669 | def test_destroy_issues_and_reassign_time_entries_to_another_issue |
|
669 | 670 | @request.session[:user_id] = 2 |
|
670 | 671 | post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2 |
|
671 | 672 | assert_redirected_to 'projects/ecookbook/issues' |
|
672 | 673 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
673 | 674 | assert_equal 2, TimeEntry.find(1).issue_id |
|
674 | 675 | assert_equal 2, TimeEntry.find(2).issue_id |
|
675 | 676 | end |
|
676 | 677 | |
|
677 | 678 | def test_destroy_attachment |
|
678 | 679 | issue = Issue.find(3) |
|
679 | 680 | a = issue.attachments.size |
|
680 | 681 | @request.session[:user_id] = 2 |
|
681 | 682 | post :destroy_attachment, :id => 3, :attachment_id => 1 |
|
682 | 683 | assert_redirected_to 'issues/show/3' |
|
683 | 684 | assert_nil Attachment.find_by_id(1) |
|
684 | 685 | issue.reload |
|
685 | 686 | assert_equal((a-1), issue.attachments.size) |
|
686 | 687 | j = issue.journals.find(:first, :order => 'created_on DESC') |
|
687 | 688 | assert_equal 'attachment', j.details.first.property |
|
688 | 689 | end |
|
689 | 690 | end |
@@ -1,168 +1,170 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'repositories_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class RepositoriesSubversionControllerTest < Test::Unit::TestCase |
|
25 | fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
|
25 | fixtures :projects, :users, :roles, :members, :enabled_modules, | |
|
26 | :repositories, :issues, :issue_statuses, :changesets, :changes, | |
|
27 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
|
26 | 28 | |
|
27 | 29 | # No '..' in the repository path for svn |
|
28 | 30 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' |
|
29 | 31 | |
|
30 | 32 | def setup |
|
31 | 33 | @controller = RepositoriesController.new |
|
32 | 34 | @request = ActionController::TestRequest.new |
|
33 | 35 | @response = ActionController::TestResponse.new |
|
34 | 36 | Setting.default_language = 'en' |
|
35 | 37 | User.current = nil |
|
36 | 38 | end |
|
37 | 39 | |
|
38 | 40 | if File.directory?(REPOSITORY_PATH) |
|
39 | 41 | def test_show |
|
40 | 42 | get :show, :id => 1 |
|
41 | 43 | assert_response :success |
|
42 | 44 | assert_template 'show' |
|
43 | 45 | assert_not_nil assigns(:entries) |
|
44 | 46 | assert_not_nil assigns(:changesets) |
|
45 | 47 | end |
|
46 | 48 | |
|
47 | 49 | def test_browse_root |
|
48 | 50 | get :browse, :id => 1 |
|
49 | 51 | assert_response :success |
|
50 | 52 | assert_template 'browse' |
|
51 | 53 | assert_not_nil assigns(:entries) |
|
52 | 54 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
|
53 | 55 | assert_equal 'dir', entry.kind |
|
54 | 56 | end |
|
55 | 57 | |
|
56 | 58 | def test_browse_directory |
|
57 | 59 | get :browse, :id => 1, :path => ['subversion_test'] |
|
58 | 60 | assert_response :success |
|
59 | 61 | assert_template 'browse' |
|
60 | 62 | assert_not_nil assigns(:entries) |
|
61 | 63 | assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name) |
|
62 | 64 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
63 | 65 | assert_equal 'file', entry.kind |
|
64 | 66 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
65 | 67 | end |
|
66 | 68 | |
|
67 | 69 | def test_browse_at_given_revision |
|
68 | 70 | get :browse, :id => 1, :path => ['subversion_test'], :rev => 4 |
|
69 | 71 | assert_response :success |
|
70 | 72 | assert_template 'browse' |
|
71 | 73 | assert_not_nil assigns(:entries) |
|
72 | 74 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name) |
|
73 | 75 | end |
|
74 | 76 | |
|
75 | 77 | def test_changes |
|
76 | 78 | get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ] |
|
77 | 79 | assert_response :success |
|
78 | 80 | assert_template 'changes' |
|
79 | 81 | # svn properties |
|
80 | 82 | assert_not_nil assigns(:properties) |
|
81 | 83 | assert_equal 'native', assigns(:properties)['svn:eol-style'] |
|
82 | 84 | assert_tag :ul, |
|
83 | 85 | :child => { :tag => 'li', |
|
84 | 86 | :child => { :tag => 'b', :content => 'svn:eol-style' }, |
|
85 | 87 | :child => { :tag => 'span', :content => 'native' } } |
|
86 | 88 | end |
|
87 | 89 | |
|
88 | 90 | def test_entry |
|
89 | 91 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'] |
|
90 | 92 | assert_response :success |
|
91 | 93 | assert_template 'entry' |
|
92 | 94 | end |
|
93 | 95 | |
|
94 | 96 | def test_entry_at_given_revision |
|
95 | 97 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 |
|
96 | 98 | assert_response :success |
|
97 | 99 | assert_template 'entry' |
|
98 | 100 | # this line was removed in r3 and file was moved in r6 |
|
99 | 101 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
|
100 | 102 | :content => /Here's the code/ |
|
101 | 103 | end |
|
102 | 104 | |
|
103 | 105 | def test_entry_not_found |
|
104 | 106 | get :entry, :id => 1, :path => ['subversion_test', 'zzz.c'] |
|
105 | 107 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
|
106 | 108 | :content => /The entry or revision was not found in the repository/ |
|
107 | 109 | end |
|
108 | 110 | |
|
109 | 111 | def test_entry_download |
|
110 | 112 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' |
|
111 | 113 | assert_response :success |
|
112 | 114 | end |
|
113 | 115 | |
|
114 | 116 | def test_directory_entry |
|
115 | 117 | get :entry, :id => 1, :path => ['subversion_test', 'folder'] |
|
116 | 118 | assert_response :success |
|
117 | 119 | assert_template 'browse' |
|
118 | 120 | assert_not_nil assigns(:entry) |
|
119 | 121 | assert_equal 'folder', assigns(:entry).name |
|
120 | 122 | end |
|
121 | 123 | |
|
122 | 124 | def test_revision |
|
123 | 125 | get :revision, :id => 1, :rev => 2 |
|
124 | 126 | assert_response :success |
|
125 | 127 | assert_template 'revision' |
|
126 | 128 | assert_tag :tag => 'tr', |
|
127 | 129 | :child => { :tag => 'td', |
|
128 | 130 | # link to the entry at rev 2 |
|
129 | 131 | :child => { :tag => 'a', :attributes => {:href => 'repositories/entry/ecookbook/test/some/path/in/the/repo?rev=2'}, |
|
130 | 132 | :content => %r{/test/some/path/in/the/repo} } |
|
131 | 133 | }, |
|
132 | 134 | :child => { :tag => 'td', |
|
133 | 135 | # link to partial diff |
|
134 | 136 | :child => { :tag => 'a', :attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' } } |
|
135 | 137 | } |
|
136 | 138 | end |
|
137 | 139 | |
|
138 | 140 | def test_revision_with_repository_pointing_to_a_subdirectory |
|
139 | 141 | r = Project.find(1).repository |
|
140 | 142 | # Changes repository url to a subdirectory |
|
141 | 143 | r.update_attribute :url, (r.url + '/test/some') |
|
142 | 144 | |
|
143 | 145 | get :revision, :id => 1, :rev => 2 |
|
144 | 146 | assert_response :success |
|
145 | 147 | assert_template 'revision' |
|
146 | 148 | assert_tag :tag => 'tr', |
|
147 | 149 | :child => { :tag => 'td', :content => %r{/test/some/path/in/the/repo} }, |
|
148 | 150 | :child => { :tag => 'td', |
|
149 | 151 | :child => { :tag => 'a', :attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' } } |
|
150 | 152 | } |
|
151 | 153 | end |
|
152 | 154 | |
|
153 | 155 | def test_diff |
|
154 | 156 | get :diff, :id => 1, :rev => 3 |
|
155 | 157 | assert_response :success |
|
156 | 158 | assert_template 'diff' |
|
157 | 159 | end |
|
158 | 160 | |
|
159 | 161 | def test_annotate |
|
160 | 162 | get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c'] |
|
161 | 163 | assert_response :success |
|
162 | 164 | assert_template 'annotate' |
|
163 | 165 | end |
|
164 | 166 | else |
|
165 | 167 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" |
|
166 | 168 | def test_fake; assert true end |
|
167 | 169 | end |
|
168 | 170 | end |
General Comments 0
You need to be logged in to leave comments.
Login now