##// END OF EJS Templates
Typo that makes the checkbox not visible (#5605)....
Jean-Philippe Lang -
r11072:0380292ecae6
parent child
Show More
@@ -1,75 +1,75
1 1 <%= error_messages_for 'project' %>
2 2
3 3 <div class="box tabular">
4 4 <!--[form:project]-->
5 5 <p><%= f.text_field :name, :required => true, :size => 60 %></p>
6 6
7 7 <p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p>
8 8 <p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
9 9 <% unless @project.identifier_frozen? %>
10 10 <em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
11 11 <% end %></p>
12 12 <p><%= f.text_field :homepage, :size => 60 %></p>
13 13 <p><%= f.check_box :is_public %></p>
14 14
15 15 <% unless @project.allowed_parents.compact.empty? %>
16 16 <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p>
17 17 <% end %>
18 18
19 <% if @project.safe_attribute? 'priority_id' %>
19 <% if @project.safe_attribute? 'inherit_members' %>
20 20 <p><%= f.check_box :inherit_members %></p>
21 21 <% end %>
22 22
23 23 <%= wikitoolbar_for 'project_description' %>
24 24
25 25 <% @project.custom_field_values.each do |value| %>
26 26 <p><%= custom_field_tag_with_label :project, value %></p>
27 27 <% end %>
28 28 <%= call_hook(:view_projects_form, :project => @project, :form => f) %>
29 29 </div>
30 30
31 31 <% if @project.new_record? %>
32 32 <fieldset class="box tabular"><legend><%= l(:label_module_plural) %></legend>
33 33 <% Redmine::AccessControl.available_project_modules.each do |m| %>
34 34 <label class="floating">
35 35 <%= check_box_tag 'project[enabled_module_names][]', m, @project.module_enabled?(m), :id => "project_enabled_module_names_#{m}" %>
36 36 <%= l_or_humanize(m, :prefix => "project_module_") %>
37 37 </label>
38 38 <% end %>
39 39 <%= hidden_field_tag 'project[enabled_module_names][]', '' %>
40 40 <%= javascript_tag 'observeProjectModules()' %>
41 41 </fieldset>
42 42 <% end %>
43 43
44 44 <% if @project.new_record? || @project.module_enabled?('issue_tracking') %>
45 45 <% unless @trackers.empty? %>
46 46 <fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend>
47 47 <% @trackers.each do |tracker| %>
48 48 <label class="floating">
49 49 <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker) %>
50 50 <%=h tracker %>
51 51 </label>
52 52 <% end %>
53 53 <%= hidden_field_tag 'project[tracker_ids][]', '' %>
54 54 </fieldset>
55 55 <% end %>
56 56
57 57 <% unless @issue_custom_fields.empty? %>
58 58 <fieldset class="box tabular" id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend>
59 59 <% @issue_custom_fields.each do |custom_field| %>
60 60 <label class="floating">
61 61 <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
62 62 <%=h custom_field.name %>
63 63 </label>
64 64 <% end %>
65 65 <%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %>
66 66 </fieldset>
67 67 <% end %>
68 68 <% end %>
69 69 <!--[eoform:project]-->
70 70
71 71 <% unless @project.identifier_frozen? %>
72 72 <% content_for :header_tags do %>
73 73 <%= javascript_include_tag 'project_identifier' %>
74 74 <% end %>
75 75 <% end %>
@@ -1,597 +1,599
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 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.expand_path('../../test_helper', __FILE__)
19 19
20 20 class ProjectsControllerTest < ActionController::TestCase
21 21 fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
22 22 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
23 23 :attachments, :custom_fields, :custom_values, :time_entries
24 24
25 25 def setup
26 26 @request.session[:user_id] = nil
27 27 Setting.default_language = 'en'
28 28 end
29 29
30 30 def test_index
31 31 get :index
32 32 assert_response :success
33 33 assert_template 'index'
34 34 assert_not_nil assigns(:projects)
35 35
36 36 assert_tag :ul, :child => {:tag => 'li',
37 37 :descendant => {:tag => 'a', :content => 'eCookbook'},
38 38 :child => { :tag => 'ul',
39 39 :descendant => { :tag => 'a',
40 40 :content => 'Child of private child'
41 41 }
42 42 }
43 43 }
44 44
45 45 assert_no_tag :a, :content => /Private child of eCookbook/
46 46 end
47 47
48 48 def test_index_atom
49 49 get :index, :format => 'atom'
50 50 assert_response :success
51 51 assert_template 'common/feed'
52 52 assert_select 'feed>title', :text => 'Redmine: Latest projects'
53 53 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current))
54 54 end
55 55
56 56 context "#index" do
57 57 context "by non-admin user with view_time_entries permission" do
58 58 setup do
59 59 @request.session[:user_id] = 3
60 60 end
61 61 should "show overall spent time link" do
62 62 get :index
63 63 assert_template 'index'
64 64 assert_tag :a, :attributes => {:href => '/time_entries'}
65 65 end
66 66 end
67 67
68 68 context "by non-admin user without view_time_entries permission" do
69 69 setup do
70 70 Role.find(2).remove_permission! :view_time_entries
71 71 Role.non_member.remove_permission! :view_time_entries
72 72 Role.anonymous.remove_permission! :view_time_entries
73 73 @request.session[:user_id] = 3
74 74 end
75 75 should "not show overall spent time link" do
76 76 get :index
77 77 assert_template 'index'
78 78 assert_no_tag :a, :attributes => {:href => '/time_entries'}
79 79 end
80 80 end
81 81 end
82 82
83 83 context "#new" do
84 84 context "by admin user" do
85 85 setup do
86 86 @request.session[:user_id] = 1
87 87 end
88 88
89 89 should "accept get" do
90 90 get :new
91 91 assert_response :success
92 92 assert_template 'new'
93 93 end
94 94
95 95 end
96 96
97 97 context "by non-admin user with add_project permission" do
98 98 setup do
99 99 Role.non_member.add_permission! :add_project
100 100 @request.session[:user_id] = 9
101 101 end
102 102
103 103 should "accept get" do
104 104 get :new
105 105 assert_response :success
106 106 assert_template 'new'
107 107 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
108 108 end
109 109 end
110 110
111 111 context "by non-admin user with add_subprojects permission" do
112 112 setup do
113 113 Role.find(1).remove_permission! :add_project
114 114 Role.find(1).add_permission! :add_subprojects
115 115 @request.session[:user_id] = 2
116 116 end
117 117
118 118 should "accept get" do
119 119 get :new, :parent_id => 'ecookbook'
120 120 assert_response :success
121 121 assert_template 'new'
122 122 # parent project selected
123 123 assert_tag :select, :attributes => {:name => 'project[parent_id]'},
124 124 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
125 125 # no empty value
126 126 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'},
127 127 :child => {:tag => 'option', :attributes => {:value => ''}}
128 128 end
129 129 end
130 130
131 131 end
132 132
133 133 context "POST :create" do
134 134 context "by admin user" do
135 135 setup do
136 136 @request.session[:user_id] = 1
137 137 end
138 138
139 139 should "create a new project" do
140 140 post :create,
141 141 :project => {
142 142 :name => "blog",
143 143 :description => "weblog",
144 144 :homepage => 'http://weblog',
145 145 :identifier => "blog",
146 146 :is_public => 1,
147 147 :custom_field_values => { '3' => 'Beta' },
148 148 :tracker_ids => ['1', '3'],
149 149 # an issue custom field that is not for all project
150 150 :issue_custom_field_ids => ['9'],
151 151 :enabled_module_names => ['issue_tracking', 'news', 'repository']
152 152 }
153 153 assert_redirected_to '/projects/blog/settings'
154 154
155 155 project = Project.find_by_name('blog')
156 156 assert_kind_of Project, project
157 157 assert project.active?
158 158 assert_equal 'weblog', project.description
159 159 assert_equal 'http://weblog', project.homepage
160 160 assert_equal true, project.is_public?
161 161 assert_nil project.parent
162 162 assert_equal 'Beta', project.custom_value_for(3).value
163 163 assert_equal [1, 3], project.trackers.map(&:id).sort
164 164 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
165 165 assert project.issue_custom_fields.include?(IssueCustomField.find(9))
166 166 end
167 167
168 168 should "create a new subproject" do
169 169 post :create, :project => { :name => "blog",
170 170 :description => "weblog",
171 171 :identifier => "blog",
172 172 :is_public => 1,
173 173 :custom_field_values => { '3' => 'Beta' },
174 174 :parent_id => 1
175 175 }
176 176 assert_redirected_to '/projects/blog/settings'
177 177
178 178 project = Project.find_by_name('blog')
179 179 assert_kind_of Project, project
180 180 assert_equal Project.find(1), project.parent
181 181 end
182 182
183 183 should "continue" do
184 184 assert_difference 'Project.count' do
185 185 post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue'
186 186 end
187 187 assert_redirected_to '/projects/new'
188 188 end
189 189 end
190 190
191 191 context "by non-admin user with add_project permission" do
192 192 setup do
193 193 Role.non_member.add_permission! :add_project
194 194 @request.session[:user_id] = 9
195 195 end
196 196
197 197 should "accept create a Project" do
198 198 post :create, :project => { :name => "blog",
199 199 :description => "weblog",
200 200 :identifier => "blog",
201 201 :is_public => 1,
202 202 :custom_field_values => { '3' => 'Beta' },
203 203 :tracker_ids => ['1', '3'],
204 204 :enabled_module_names => ['issue_tracking', 'news', 'repository']
205 205 }
206 206
207 207 assert_redirected_to '/projects/blog/settings'
208 208
209 209 project = Project.find_by_name('blog')
210 210 assert_kind_of Project, project
211 211 assert_equal 'weblog', project.description
212 212 assert_equal true, project.is_public?
213 213 assert_equal [1, 3], project.trackers.map(&:id).sort
214 214 assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
215 215
216 216 # User should be added as a project member
217 217 assert User.find(9).member_of?(project)
218 218 assert_equal 1, project.members.size
219 219 end
220 220
221 221 should "fail with parent_id" do
222 222 assert_no_difference 'Project.count' do
223 223 post :create, :project => { :name => "blog",
224 224 :description => "weblog",
225 225 :identifier => "blog",
226 226 :is_public => 1,
227 227 :custom_field_values => { '3' => 'Beta' },
228 228 :parent_id => 1
229 229 }
230 230 end
231 231 assert_response :success
232 232 project = assigns(:project)
233 233 assert_kind_of Project, project
234 234 assert_not_nil project.errors[:parent_id]
235 235 end
236 236 end
237 237
238 238 context "by non-admin user with add_subprojects permission" do
239 239 setup do
240 240 Role.find(1).remove_permission! :add_project
241 241 Role.find(1).add_permission! :add_subprojects
242 242 @request.session[:user_id] = 2
243 243 end
244 244
245 245 should "create a project with a parent_id" do
246 246 post :create, :project => { :name => "blog",
247 247 :description => "weblog",
248 248 :identifier => "blog",
249 249 :is_public => 1,
250 250 :custom_field_values => { '3' => 'Beta' },
251 251 :parent_id => 1
252 252 }
253 253 assert_redirected_to '/projects/blog/settings'
254 254 project = Project.find_by_name('blog')
255 255 end
256 256
257 257 should "fail without parent_id" do
258 258 assert_no_difference 'Project.count' do
259 259 post :create, :project => { :name => "blog",
260 260 :description => "weblog",
261 261 :identifier => "blog",
262 262 :is_public => 1,
263 263 :custom_field_values => { '3' => 'Beta' }
264 264 }
265 265 end
266 266 assert_response :success
267 267 project = assigns(:project)
268 268 assert_kind_of Project, project
269 269 assert_not_nil project.errors[:parent_id]
270 270 end
271 271
272 272 should "fail with unauthorized parent_id" do
273 273 assert !User.find(2).member_of?(Project.find(6))
274 274 assert_no_difference 'Project.count' do
275 275 post :create, :project => { :name => "blog",
276 276 :description => "weblog",
277 277 :identifier => "blog",
278 278 :is_public => 1,
279 279 :custom_field_values => { '3' => 'Beta' },
280 280 :parent_id => 6
281 281 }
282 282 end
283 283 assert_response :success
284 284 project = assigns(:project)
285 285 assert_kind_of Project, project
286 286 assert_not_nil project.errors[:parent_id]
287 287 end
288 288 end
289 289 end
290 290
291 291 def test_create_subproject_with_inherit_members_should_inherit_members
292 292 Role.find_by_name('Manager').add_permission! :add_subprojects
293 293 parent = Project.find(1)
294 294 @request.session[:user_id] = 2
295 295
296 296 assert_difference 'Project.count' do
297 297 post :create, :project => {
298 298 :name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1'
299 299 }
300 300 assert_response 302
301 301 end
302 302
303 303 project = Project.order('id desc').first
304 304 assert_equal 'inherited', project.name
305 305 assert_equal parent, project.parent
306 306 assert project.memberships.count > 0
307 307 assert_equal parent.memberships.count, project.memberships.count
308 308 end
309 309
310 310 def test_create_should_preserve_modules_on_validation_failure
311 311 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
312 312 @request.session[:user_id] = 1
313 313 assert_no_difference 'Project.count' do
314 314 post :create, :project => {
315 315 :name => "blog",
316 316 :identifier => "",
317 317 :enabled_module_names => %w(issue_tracking news)
318 318 }
319 319 end
320 320 assert_response :success
321 321 project = assigns(:project)
322 322 assert_equal %w(issue_tracking news), project.enabled_module_names.sort
323 323 end
324 324 end
325 325
326 326 def test_show_by_id
327 327 get :show, :id => 1
328 328 assert_response :success
329 329 assert_template 'show'
330 330 assert_not_nil assigns(:project)
331 331 end
332 332
333 333 def test_show_by_identifier
334 334 get :show, :id => 'ecookbook'
335 335 assert_response :success
336 336 assert_template 'show'
337 337 assert_not_nil assigns(:project)
338 338 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
339 339
340 340 assert_tag 'li', :content => /Development status/
341 341 end
342 342
343 343 def test_show_should_not_display_hidden_custom_fields
344 344 ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
345 345 get :show, :id => 'ecookbook'
346 346 assert_response :success
347 347 assert_template 'show'
348 348 assert_not_nil assigns(:project)
349 349
350 350 assert_no_tag 'li', :content => /Development status/
351 351 end
352 352
353 353 def test_show_should_not_fail_when_custom_values_are_nil
354 354 project = Project.find_by_identifier('ecookbook')
355 355 project.custom_values.first.update_attribute(:value, nil)
356 356 get :show, :id => 'ecookbook'
357 357 assert_response :success
358 358 assert_template 'show'
359 359 assert_not_nil assigns(:project)
360 360 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
361 361 end
362 362
363 363 def show_archived_project_should_be_denied
364 364 project = Project.find_by_identifier('ecookbook')
365 365 project.archive!
366 366
367 367 get :show, :id => 'ecookbook'
368 368 assert_response 403
369 369 assert_nil assigns(:project)
370 370 assert_tag :tag => 'p', :content => /archived/
371 371 end
372 372
373 373 def test_private_subprojects_hidden
374 374 get :show, :id => 'ecookbook'
375 375 assert_response :success
376 376 assert_template 'show'
377 377 assert_no_tag :tag => 'a', :content => /Private child/
378 378 end
379 379
380 380 def test_private_subprojects_visible
381 381 @request.session[:user_id] = 2 # manager who is a member of the private subproject
382 382 get :show, :id => 'ecookbook'
383 383 assert_response :success
384 384 assert_template 'show'
385 385 assert_tag :tag => 'a', :content => /Private child/
386 386 end
387 387
388 388 def test_settings
389 389 @request.session[:user_id] = 2 # manager
390 390 get :settings, :id => 1
391 391 assert_response :success
392 392 assert_template 'settings'
393 393 end
394 394
395 395 def test_settings_of_subproject
396 396 @request.session[:user_id] = 2
397 397 get :settings, :id => 'private-child'
398 398 assert_response :success
399 399 assert_template 'settings'
400
401 assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
400 402 end
401 403
402 404 def test_settings_should_be_denied_for_member_on_closed_project
403 405 Project.find(1).close
404 406 @request.session[:user_id] = 2 # manager
405 407
406 408 get :settings, :id => 1
407 409 assert_response 403
408 410 end
409 411
410 412 def test_settings_should_be_denied_for_anonymous_on_closed_project
411 413 Project.find(1).close
412 414
413 415 get :settings, :id => 1
414 416 assert_response 302
415 417 end
416 418
417 419 def test_update
418 420 @request.session[:user_id] = 2 # manager
419 421 post :update, :id => 1, :project => {:name => 'Test changed name',
420 422 :issue_custom_field_ids => ['']}
421 423 assert_redirected_to '/projects/ecookbook/settings'
422 424 project = Project.find(1)
423 425 assert_equal 'Test changed name', project.name
424 426 end
425 427
426 428 def test_update_with_failure
427 429 @request.session[:user_id] = 2 # manager
428 430 post :update, :id => 1, :project => {:name => ''}
429 431 assert_response :success
430 432 assert_template 'settings'
431 433 assert_error_tag :content => /name can&#x27;t be blank/i
432 434 end
433 435
434 436 def test_update_should_be_denied_for_member_on_closed_project
435 437 Project.find(1).close
436 438 @request.session[:user_id] = 2 # manager
437 439
438 440 post :update, :id => 1, :project => {:name => 'Closed'}
439 441 assert_response 403
440 442 assert_equal 'eCookbook', Project.find(1).name
441 443 end
442 444
443 445 def test_update_should_be_denied_for_anonymous_on_closed_project
444 446 Project.find(1).close
445 447
446 448 post :update, :id => 1, :project => {:name => 'Closed'}
447 449 assert_response 302
448 450 assert_equal 'eCookbook', Project.find(1).name
449 451 end
450 452
451 453 def test_modules
452 454 @request.session[:user_id] = 2
453 455 Project.find(1).enabled_module_names = ['issue_tracking', 'news']
454 456
455 457 post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents']
456 458 assert_redirected_to '/projects/ecookbook/settings/modules'
457 459 assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
458 460 end
459 461
460 462 def test_destroy_without_confirmation
461 463 @request.session[:user_id] = 1 # admin
462 464 delete :destroy, :id => 1
463 465 assert_response :success
464 466 assert_template 'destroy'
465 467 assert_not_nil Project.find_by_id(1)
466 468 assert_tag :tag => 'strong',
467 469 :content => ['Private child of eCookbook',
468 470 'Child of private child, eCookbook Subproject 1',
469 471 'eCookbook Subproject 2'].join(', ')
470 472 end
471 473
472 474 def test_destroy
473 475 @request.session[:user_id] = 1 # admin
474 476 delete :destroy, :id => 1, :confirm => 1
475 477 assert_redirected_to '/admin/projects'
476 478 assert_nil Project.find_by_id(1)
477 479 end
478 480
479 481 def test_archive
480 482 @request.session[:user_id] = 1 # admin
481 483 post :archive, :id => 1
482 484 assert_redirected_to '/admin/projects'
483 485 assert !Project.find(1).active?
484 486 end
485 487
486 488 def test_archive_with_failure
487 489 @request.session[:user_id] = 1
488 490 Project.any_instance.stubs(:archive).returns(false)
489 491 post :archive, :id => 1
490 492 assert_redirected_to '/admin/projects'
491 493 assert_match /project cannot be archived/i, flash[:error]
492 494 end
493 495
494 496 def test_unarchive
495 497 @request.session[:user_id] = 1 # admin
496 498 Project.find(1).archive
497 499 post :unarchive, :id => 1
498 500 assert_redirected_to '/admin/projects'
499 501 assert Project.find(1).active?
500 502 end
501 503
502 504 def test_close
503 505 @request.session[:user_id] = 2
504 506 post :close, :id => 1
505 507 assert_redirected_to '/projects/ecookbook'
506 508 assert_equal Project::STATUS_CLOSED, Project.find(1).status
507 509 end
508 510
509 511 def test_reopen
510 512 Project.find(1).close
511 513 @request.session[:user_id] = 2
512 514 post :reopen, :id => 1
513 515 assert_redirected_to '/projects/ecookbook'
514 516 assert Project.find(1).active?
515 517 end
516 518
517 519 def test_project_breadcrumbs_should_be_limited_to_3_ancestors
518 520 CustomField.delete_all
519 521 parent = nil
520 522 6.times do |i|
521 523 p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
522 524 p.set_parent!(parent)
523 525 get :show, :id => p
524 526 assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
525 527 :children => { :count => [i, 3].min,
526 528 :only => { :tag => 'a' } }
527 529
528 530 parent = p
529 531 end
530 532 end
531 533
532 534 def test_get_copy
533 535 @request.session[:user_id] = 1 # admin
534 536 get :copy, :id => 1
535 537 assert_response :success
536 538 assert_template 'copy'
537 539 assert assigns(:project)
538 540 assert_equal Project.find(1).description, assigns(:project).description
539 541 assert_nil assigns(:project).id
540 542
541 543 assert_tag :tag => 'input',
542 544 :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'}
543 545 end
544 546
545 547 def test_get_copy_with_invalid_source_should_respond_with_404
546 548 @request.session[:user_id] = 1
547 549 get :copy, :id => 99
548 550 assert_response 404
549 551 end
550 552
551 553 def test_post_copy_should_copy_requested_items
552 554 @request.session[:user_id] = 1 # admin
553 555 CustomField.delete_all
554 556
555 557 assert_difference 'Project.count' do
556 558 post :copy, :id => 1,
557 559 :project => {
558 560 :name => 'Copy',
559 561 :identifier => 'unique-copy',
560 562 :tracker_ids => ['1', '2', '3', ''],
561 563 :enabled_module_names => %w(issue_tracking time_tracking)
562 564 },
563 565 :only => %w(issues versions)
564 566 end
565 567 project = Project.find('unique-copy')
566 568 source = Project.find(1)
567 569 assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort
568 570
569 571 assert_equal source.versions.count, project.versions.count, "All versions were not copied"
570 572 assert_equal source.issues.count, project.issues.count, "All issues were not copied"
571 573 assert_equal 0, project.members.count
572 574 end
573 575
574 576 def test_post_copy_should_redirect_to_settings_when_successful
575 577 @request.session[:user_id] = 1 # admin
576 578 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
577 579 assert_response :redirect
578 580 assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
579 581 end
580 582
581 583 def test_jump_should_redirect_to_active_tab
582 584 get :show, :id => 1, :jump => 'issues'
583 585 assert_redirected_to '/projects/ecookbook/issues'
584 586 end
585 587
586 588 def test_jump_should_not_redirect_to_inactive_tab
587 589 get :show, :id => 3, :jump => 'documents'
588 590 assert_response :success
589 591 assert_template 'show'
590 592 end
591 593
592 594 def test_jump_should_not_redirect_to_unknown_tab
593 595 get :show, :id => 3, :jump => 'foobar'
594 596 assert_response :success
595 597 assert_template 'show'
596 598 end
597 599 end
General Comments 0
You need to be logged in to leave comments. Login now