Mercurial > hg > soundsoftware-site
comparison test/functional/projects_controller_test.rb @ 22:40f7cfd4df19
* Update to SVN trunk rev 4173
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:06:04 +0100 |
parents | 513646585e45 |
children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
14:1d32c0a0efbf | 22:40f7cfd4df19 |
---|---|
85 assert_no_tag :a, :attributes => {:href => '/time_entries'} | 85 assert_no_tag :a, :attributes => {:href => '/time_entries'} |
86 end | 86 end |
87 end | 87 end |
88 end | 88 end |
89 | 89 |
90 context "#add" do | 90 context "#new" do |
91 context "by admin user" do | 91 context "by admin user" do |
92 setup do | 92 setup do |
93 @request.session[:user_id] = 1 | 93 @request.session[:user_id] = 1 |
94 end | 94 end |
95 | 95 |
96 should "accept get" do | 96 should "accept get" do |
97 get :add | 97 get :new |
98 assert_response :success | 98 assert_response :success |
99 assert_template 'add' | 99 assert_template 'new' |
100 end | 100 end |
101 | 101 |
102 should "accept post" do | 102 end |
103 post :add, :project => { :name => "blog", | 103 |
104 context "by non-admin user with add_project permission" do | |
105 setup do | |
106 Role.non_member.add_permission! :add_project | |
107 @request.session[:user_id] = 9 | |
108 end | |
109 | |
110 should "accept get" do | |
111 get :new | |
112 assert_response :success | |
113 assert_template 'new' | |
114 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} | |
115 end | |
116 end | |
117 | |
118 context "by non-admin user with add_subprojects permission" do | |
119 setup do | |
120 Role.find(1).remove_permission! :add_project | |
121 Role.find(1).add_permission! :add_subprojects | |
122 @request.session[:user_id] = 2 | |
123 end | |
124 | |
125 should "accept get" do | |
126 get :new, :parent_id => 'ecookbook' | |
127 assert_response :success | |
128 assert_template 'new' | |
129 # parent project selected | |
130 assert_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
131 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} | |
132 # no empty value | |
133 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
134 :child => {:tag => 'option', :attributes => {:value => ''}} | |
135 end | |
136 end | |
137 | |
138 end | |
139 | |
140 context "POST :create" do | |
141 context "by admin user" do | |
142 setup do | |
143 @request.session[:user_id] = 1 | |
144 end | |
145 | |
146 should "create a new project" do | |
147 post :create, :project => { :name => "blog", | |
104 :description => "weblog", | 148 :description => "weblog", |
105 :identifier => "blog", | 149 :identifier => "blog", |
106 :is_public => 1, | 150 :is_public => 1, |
107 :custom_field_values => { '3' => 'Beta' } | 151 :custom_field_values => { '3' => 'Beta' } |
108 } | 152 } |
113 assert_equal 'weblog', project.description | 157 assert_equal 'weblog', project.description |
114 assert_equal true, project.is_public? | 158 assert_equal true, project.is_public? |
115 assert_nil project.parent | 159 assert_nil project.parent |
116 end | 160 end |
117 | 161 |
118 should "accept post with parent" do | 162 should "create a new subproject" do |
119 post :add, :project => { :name => "blog", | 163 post :create, :project => { :name => "blog", |
120 :description => "weblog", | 164 :description => "weblog", |
121 :identifier => "blog", | 165 :identifier => "blog", |
122 :is_public => 1, | 166 :is_public => 1, |
123 :custom_field_values => { '3' => 'Beta' }, | 167 :custom_field_values => { '3' => 'Beta' }, |
124 :parent_id => 1 | 168 :parent_id => 1 |
135 setup do | 179 setup do |
136 Role.non_member.add_permission! :add_project | 180 Role.non_member.add_permission! :add_project |
137 @request.session[:user_id] = 9 | 181 @request.session[:user_id] = 9 |
138 end | 182 end |
139 | 183 |
140 should "accept get" do | 184 should "accept create a Project" do |
141 get :add | 185 post :create, :project => { :name => "blog", |
142 assert_response :success | |
143 assert_template 'add' | |
144 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} | |
145 end | |
146 | |
147 should "accept post" do | |
148 post :add, :project => { :name => "blog", | |
149 :description => "weblog", | 186 :description => "weblog", |
150 :identifier => "blog", | 187 :identifier => "blog", |
151 :is_public => 1, | 188 :is_public => 1, |
152 :custom_field_values => { '3' => 'Beta' } | 189 :custom_field_values => { '3' => 'Beta' } |
153 } | 190 } |
164 assert_equal 1, project.members.size | 201 assert_equal 1, project.members.size |
165 end | 202 end |
166 | 203 |
167 should "fail with parent_id" do | 204 should "fail with parent_id" do |
168 assert_no_difference 'Project.count' do | 205 assert_no_difference 'Project.count' do |
169 post :add, :project => { :name => "blog", | 206 post :create, :project => { :name => "blog", |
170 :description => "weblog", | 207 :description => "weblog", |
171 :identifier => "blog", | 208 :identifier => "blog", |
172 :is_public => 1, | 209 :is_public => 1, |
173 :custom_field_values => { '3' => 'Beta' }, | 210 :custom_field_values => { '3' => 'Beta' }, |
174 :parent_id => 1 | 211 :parent_id => 1 |
186 Role.find(1).remove_permission! :add_project | 223 Role.find(1).remove_permission! :add_project |
187 Role.find(1).add_permission! :add_subprojects | 224 Role.find(1).add_permission! :add_subprojects |
188 @request.session[:user_id] = 2 | 225 @request.session[:user_id] = 2 |
189 end | 226 end |
190 | 227 |
191 should "accept get" do | 228 should "create a project with a parent_id" do |
192 get :add, :parent_id => 'ecookbook' | 229 post :create, :project => { :name => "blog", |
193 assert_response :success | |
194 assert_template 'add' | |
195 # parent project selected | |
196 assert_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
197 :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} | |
198 # no empty value | |
199 assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
200 :child => {:tag => 'option', :attributes => {:value => ''}} | |
201 end | |
202 | |
203 should "accept post with parent_id" do | |
204 post :add, :project => { :name => "blog", | |
205 :description => "weblog", | 230 :description => "weblog", |
206 :identifier => "blog", | 231 :identifier => "blog", |
207 :is_public => 1, | 232 :is_public => 1, |
208 :custom_field_values => { '3' => 'Beta' }, | 233 :custom_field_values => { '3' => 'Beta' }, |
209 :parent_id => 1 | 234 :parent_id => 1 |
212 project = Project.find_by_name('blog') | 237 project = Project.find_by_name('blog') |
213 end | 238 end |
214 | 239 |
215 should "fail without parent_id" do | 240 should "fail without parent_id" do |
216 assert_no_difference 'Project.count' do | 241 assert_no_difference 'Project.count' do |
217 post :add, :project => { :name => "blog", | 242 post :create, :project => { :name => "blog", |
218 :description => "weblog", | 243 :description => "weblog", |
219 :identifier => "blog", | 244 :identifier => "blog", |
220 :is_public => 1, | 245 :is_public => 1, |
221 :custom_field_values => { '3' => 'Beta' } | 246 :custom_field_values => { '3' => 'Beta' } |
222 } | 247 } |
228 end | 253 end |
229 | 254 |
230 should "fail with unauthorized parent_id" do | 255 should "fail with unauthorized parent_id" do |
231 assert !User.find(2).member_of?(Project.find(6)) | 256 assert !User.find(2).member_of?(Project.find(6)) |
232 assert_no_difference 'Project.count' do | 257 assert_no_difference 'Project.count' do |
233 post :add, :project => { :name => "blog", | 258 post :create, :project => { :name => "blog", |
234 :description => "weblog", | 259 :description => "weblog", |
235 :identifier => "blog", | 260 :identifier => "blog", |
236 :is_public => 1, | 261 :is_public => 1, |
237 :custom_field_values => { '3' => 'Beta' }, | 262 :custom_field_values => { '3' => 'Beta' }, |
238 :parent_id => 6 | 263 :parent_id => 6 |
291 get :settings, :id => 1 | 316 get :settings, :id => 1 |
292 assert_response :success | 317 assert_response :success |
293 assert_template 'settings' | 318 assert_template 'settings' |
294 end | 319 end |
295 | 320 |
296 def test_edit | 321 def test_update |
297 @request.session[:user_id] = 2 # manager | 322 @request.session[:user_id] = 2 # manager |
298 post :edit, :id => 1, :project => {:name => 'Test changed name', | 323 post :update, :id => 1, :project => {:name => 'Test changed name', |
299 :issue_custom_field_ids => ['']} | 324 :issue_custom_field_ids => ['']} |
300 assert_redirected_to 'projects/ecookbook/settings' | 325 assert_redirected_to 'projects/ecookbook/settings' |
301 project = Project.find(1) | 326 project = Project.find(1) |
302 assert_equal 'Test changed name', project.name | 327 assert_equal 'Test changed name', project.name |
303 end | 328 end |
313 def test_post_destroy | 338 def test_post_destroy |
314 @request.session[:user_id] = 1 # admin | 339 @request.session[:user_id] = 1 # admin |
315 post :destroy, :id => 1, :confirm => 1 | 340 post :destroy, :id => 1, :confirm => 1 |
316 assert_redirected_to 'admin/projects' | 341 assert_redirected_to 'admin/projects' |
317 assert_nil Project.find_by_id(1) | 342 assert_nil Project.find_by_id(1) |
318 end | |
319 | |
320 def test_add_file | |
321 set_tmp_attachments_directory | |
322 @request.session[:user_id] = 2 | |
323 Setting.notified_events = ['file_added'] | |
324 ActionMailer::Base.deliveries.clear | |
325 | |
326 assert_difference 'Attachment.count' do | |
327 post :add_file, :id => 1, :version_id => '', | |
328 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
329 end | |
330 assert_redirected_to 'projects/ecookbook/files' | |
331 a = Attachment.find(:first, :order => 'created_on DESC') | |
332 assert_equal 'testfile.txt', a.filename | |
333 assert_equal Project.find(1), a.container | |
334 | |
335 mail = ActionMailer::Base.deliveries.last | |
336 assert_kind_of TMail::Mail, mail | |
337 assert_equal "[eCookbook] New file", mail.subject | |
338 assert mail.body.include?('testfile.txt') | |
339 end | |
340 | |
341 def test_add_version_file | |
342 set_tmp_attachments_directory | |
343 @request.session[:user_id] = 2 | |
344 Setting.notified_events = ['file_added'] | |
345 | |
346 assert_difference 'Attachment.count' do | |
347 post :add_file, :id => 1, :version_id => '2', | |
348 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
349 end | |
350 assert_redirected_to 'projects/ecookbook/files' | |
351 a = Attachment.find(:first, :order => 'created_on DESC') | |
352 assert_equal 'testfile.txt', a.filename | |
353 assert_equal Version.find(2), a.container | |
354 end | |
355 | |
356 def test_list_files | |
357 get :list_files, :id => 1 | |
358 assert_response :success | |
359 assert_template 'list_files' | |
360 assert_not_nil assigns(:containers) | |
361 | |
362 # file attached to the project | |
363 assert_tag :a, :content => 'project_file.zip', | |
364 :attributes => { :href => '/attachments/download/8/project_file.zip' } | |
365 | |
366 # file attached to a project's version | |
367 assert_tag :a, :content => 'version_file.zip', | |
368 :attributes => { :href => '/attachments/download/9/version_file.zip' } | |
369 end | |
370 | |
371 def test_roadmap | |
372 get :roadmap, :id => 1 | |
373 assert_response :success | |
374 assert_template 'roadmap' | |
375 assert_not_nil assigns(:versions) | |
376 # Version with no date set appears | |
377 assert assigns(:versions).include?(Version.find(3)) | |
378 # Completed version doesn't appear | |
379 assert !assigns(:versions).include?(Version.find(1)) | |
380 end | |
381 | |
382 def test_roadmap_with_completed_versions | |
383 get :roadmap, :id => 1, :completed => 1 | |
384 assert_response :success | |
385 assert_template 'roadmap' | |
386 assert_not_nil assigns(:versions) | |
387 # Version with no date set appears | |
388 assert assigns(:versions).include?(Version.find(3)) | |
389 # Completed version appears | |
390 assert assigns(:versions).include?(Version.find(1)) | |
391 end | |
392 | |
393 def test_roadmap_showing_subprojects_versions | |
394 @subproject_version = Version.generate!(:project => Project.find(3)) | |
395 get :roadmap, :id => 1, :with_subprojects => 1 | |
396 assert_response :success | |
397 assert_template 'roadmap' | |
398 assert_not_nil assigns(:versions) | |
399 | |
400 assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |
401 assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |
402 end | |
403 def test_project_activity | |
404 get :activity, :id => 1, :with_subprojects => 0 | |
405 assert_response :success | |
406 assert_template 'activity' | |
407 assert_not_nil assigns(:events_by_day) | |
408 | |
409 assert_tag :tag => "h3", | |
410 :content => /#{2.days.ago.to_date.day}/, | |
411 :sibling => { :tag => "dl", | |
412 :child => { :tag => "dt", | |
413 :attributes => { :class => /issue-edit/ }, | |
414 :child => { :tag => "a", | |
415 :content => /(#{IssueStatus.find(2).name})/, | |
416 } | |
417 } | |
418 } | |
419 end | |
420 | |
421 def test_previous_project_activity | |
422 get :activity, :id => 1, :from => 3.days.ago.to_date | |
423 assert_response :success | |
424 assert_template 'activity' | |
425 assert_not_nil assigns(:events_by_day) | |
426 | |
427 assert_tag :tag => "h3", | |
428 :content => /#{3.day.ago.to_date.day}/, | |
429 :sibling => { :tag => "dl", | |
430 :child => { :tag => "dt", | |
431 :attributes => { :class => /issue/ }, | |
432 :child => { :tag => "a", | |
433 :content => /#{Issue.find(1).subject}/, | |
434 } | |
435 } | |
436 } | |
437 end | |
438 | |
439 def test_global_activity | |
440 get :activity | |
441 assert_response :success | |
442 assert_template 'activity' | |
443 assert_not_nil assigns(:events_by_day) | |
444 | |
445 assert_tag :tag => "h3", | |
446 :content => /#{5.day.ago.to_date.day}/, | |
447 :sibling => { :tag => "dl", | |
448 :child => { :tag => "dt", | |
449 :attributes => { :class => /issue/ }, | |
450 :child => { :tag => "a", | |
451 :content => /#{Issue.find(5).subject}/, | |
452 } | |
453 } | |
454 } | |
455 end | |
456 | |
457 def test_user_activity | |
458 get :activity, :user_id => 2 | |
459 assert_response :success | |
460 assert_template 'activity' | |
461 assert_not_nil assigns(:events_by_day) | |
462 | |
463 assert_tag :tag => "h3", | |
464 :content => /#{3.day.ago.to_date.day}/, | |
465 :sibling => { :tag => "dl", | |
466 :child => { :tag => "dt", | |
467 :attributes => { :class => /issue/ }, | |
468 :child => { :tag => "a", | |
469 :content => /#{Issue.find(1).subject}/, | |
470 } | |
471 } | |
472 } | |
473 end | |
474 | |
475 def test_activity_atom_feed | |
476 get :activity, :format => 'atom' | |
477 assert_response :success | |
478 assert_template 'common/feed.atom.rxml' | |
479 assert_tag :tag => 'entry', :child => { | |
480 :tag => 'link', | |
481 :attributes => {:href => 'http://test.host/issues/11'}} | |
482 end | 343 end |
483 | 344 |
484 def test_archive | 345 def test_archive |
485 @request.session[:user_id] = 1 # admin | 346 @request.session[:user_id] = 1 # admin |
486 post :archive, :id => 1 | 347 post :archive, :id => 1 |
543 get :show, :id => 3, :jump => 'foobar' | 404 get :show, :id => 3, :jump => 'foobar' |
544 assert_response :success | 405 assert_response :success |
545 assert_template 'show' | 406 assert_template 'show' |
546 end | 407 end |
547 | 408 |
548 def test_reset_activities | |
549 @request.session[:user_id] = 2 # manager | |
550 project_activity = TimeEntryActivity.new({ | |
551 :name => 'Project Specific', | |
552 :parent => TimeEntryActivity.find(:first), | |
553 :project => Project.find(1), | |
554 :active => true | |
555 }) | |
556 assert project_activity.save | |
557 project_activity_two = TimeEntryActivity.new({ | |
558 :name => 'Project Specific Two', | |
559 :parent => TimeEntryActivity.find(:last), | |
560 :project => Project.find(1), | |
561 :active => true | |
562 }) | |
563 assert project_activity_two.save | |
564 | |
565 delete :reset_activities, :id => 1 | |
566 assert_response :redirect | |
567 assert_redirected_to 'projects/ecookbook/settings/activities' | |
568 | |
569 assert_nil TimeEntryActivity.find_by_id(project_activity.id) | |
570 assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) | |
571 end | |
572 | |
573 def test_reset_activities_should_reassign_time_entries_back_to_the_system_activity | |
574 @request.session[:user_id] = 2 # manager | |
575 project_activity = TimeEntryActivity.new({ | |
576 :name => 'Project Specific Design', | |
577 :parent => TimeEntryActivity.find(9), | |
578 :project => Project.find(1), | |
579 :active => true | |
580 }) | |
581 assert project_activity.save | |
582 assert TimeEntry.update_all("activity_id = '#{project_activity.id}'", ["project_id = ? AND activity_id = ?", 1, 9]) | |
583 assert 3, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size | |
584 | |
585 delete :reset_activities, :id => 1 | |
586 assert_response :redirect | |
587 assert_redirected_to 'projects/ecookbook/settings/activities' | |
588 | |
589 assert_nil TimeEntryActivity.find_by_id(project_activity.id) | |
590 assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity" | |
591 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity" | |
592 end | |
593 | |
594 def test_save_activities_to_override_system_activities | |
595 @request.session[:user_id] = 2 # manager | |
596 billable_field = TimeEntryActivityCustomField.find_by_name("Billable") | |
597 | |
598 post :save_activities, :id => 1, :enumerations => { | |
599 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design, De-activate | |
600 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"}, # Development, Change custom value | |
601 "14"=>{"parent_id"=>"14", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"}, # Inactive Activity, Activate with custom value | |
602 "11"=>{"parent_id"=>"11", "custom_field_values"=>{"7"=>"1"}, "active"=>"1"} # QA, no changes | |
603 } | |
604 | |
605 assert_response :redirect | |
606 assert_redirected_to 'projects/ecookbook/settings/activities' | |
607 | |
608 # Created project specific activities... | |
609 project = Project.find('ecookbook') | |
610 | |
611 # ... Design | |
612 design = project.time_entry_activities.find_by_name("Design") | |
613 assert design, "Project activity not found" | |
614 | |
615 assert_equal 9, design.parent_id # Relate to the system activity | |
616 assert_not_equal design.parent.id, design.id # Different records | |
617 assert_equal design.parent.name, design.name # Same name | |
618 assert !design.active? | |
619 | |
620 # ... Development | |
621 development = project.time_entry_activities.find_by_name("Development") | |
622 assert development, "Project activity not found" | |
623 | |
624 assert_equal 10, development.parent_id # Relate to the system activity | |
625 assert_not_equal development.parent.id, development.id # Different records | |
626 assert_equal development.parent.name, development.name # Same name | |
627 assert development.active? | |
628 assert_equal "0", development.custom_value_for(billable_field).value | |
629 | |
630 # ... Inactive Activity | |
631 previously_inactive = project.time_entry_activities.find_by_name("Inactive Activity") | |
632 assert previously_inactive, "Project activity not found" | |
633 | |
634 assert_equal 14, previously_inactive.parent_id # Relate to the system activity | |
635 assert_not_equal previously_inactive.parent.id, previously_inactive.id # Different records | |
636 assert_equal previously_inactive.parent.name, previously_inactive.name # Same name | |
637 assert previously_inactive.active? | |
638 assert_equal "1", previously_inactive.custom_value_for(billable_field).value | |
639 | |
640 # ... QA | |
641 assert_equal nil, project.time_entry_activities.find_by_name("QA"), "Custom QA activity created when it wasn't modified" | |
642 end | |
643 | |
644 def test_save_activities_will_update_project_specific_activities | |
645 @request.session[:user_id] = 2 # manager | |
646 | |
647 project_activity = TimeEntryActivity.new({ | |
648 :name => 'Project Specific', | |
649 :parent => TimeEntryActivity.find(:first), | |
650 :project => Project.find(1), | |
651 :active => true | |
652 }) | |
653 assert project_activity.save | |
654 project_activity_two = TimeEntryActivity.new({ | |
655 :name => 'Project Specific Two', | |
656 :parent => TimeEntryActivity.find(:last), | |
657 :project => Project.find(1), | |
658 :active => true | |
659 }) | |
660 assert project_activity_two.save | |
661 | |
662 | |
663 post :save_activities, :id => 1, :enumerations => { | |
664 project_activity.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # De-activate | |
665 project_activity_two.id => {"custom_field_values"=>{"7" => "1"}, "active"=>"0"} # De-activate | |
666 } | |
667 | |
668 assert_response :redirect | |
669 assert_redirected_to 'projects/ecookbook/settings/activities' | |
670 | |
671 # Created project specific activities... | |
672 project = Project.find('ecookbook') | |
673 assert_equal 2, project.time_entry_activities.count | |
674 | |
675 activity_one = project.time_entry_activities.find_by_name(project_activity.name) | |
676 assert activity_one, "Project activity not found" | |
677 assert_equal project_activity.id, activity_one.id | |
678 assert !activity_one.active? | |
679 | |
680 activity_two = project.time_entry_activities.find_by_name(project_activity_two.name) | |
681 assert activity_two, "Project activity not found" | |
682 assert_equal project_activity_two.id, activity_two.id | |
683 assert !activity_two.active? | |
684 end | |
685 | |
686 def test_save_activities_when_creating_new_activities_will_convert_existing_data | |
687 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | |
688 | |
689 @request.session[:user_id] = 2 # manager | |
690 post :save_activities, :id => 1, :enumerations => { | |
691 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"} # Design, De-activate | |
692 } | |
693 assert_response :redirect | |
694 | |
695 # No more TimeEntries using the system activity | |
696 assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries still assigned to system activities" | |
697 # All TimeEntries using project activity | |
698 project_specific_activity = TimeEntryActivity.find_by_parent_id_and_project_id(9, 1) | |
699 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(project_specific_activity.id, 1).size, "No Time Entries assigned to the project activity" | |
700 end | |
701 | |
702 def test_save_activities_when_creating_new_activities_will_not_convert_existing_data_if_an_exception_is_raised | |
703 # TODO: Need to cause an exception on create but these tests | |
704 # aren't setup for mocking. Just create a record now so the | |
705 # second one is a dupicate | |
706 parent = TimeEntryActivity.find(9) | |
707 TimeEntryActivity.create!({:name => parent.name, :project_id => 1, :position => parent.position, :active => true}) | |
708 TimeEntry.create!({:project_id => 1, :hours => 1.0, :user => User.find(1), :issue_id => 3, :activity_id => 10, :spent_on => '2009-01-01'}) | |
709 | |
710 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size | |
711 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size | |
712 | |
713 @request.session[:user_id] = 2 # manager | |
714 post :save_activities, :id => 1, :enumerations => { | |
715 "9"=> {"parent_id"=>"9", "custom_field_values"=>{"7" => "1"}, "active"=>"0"}, # Design | |
716 "10"=> {"parent_id"=>"10", "custom_field_values"=>{"7"=>"0"}, "active"=>"1"} # Development, Change custom value | |
717 } | |
718 assert_response :redirect | |
719 | |
720 # TimeEntries shouldn't have been reassigned on the failed record | |
721 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "Time Entries are not assigned to system activities" | |
722 # TimeEntries shouldn't have been reassigned on the saved record either | |
723 assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size, "Time Entries are not assigned to system activities" | |
724 end | |
725 | |
726 # A hook that is manually registered later | 409 # A hook that is manually registered later |
727 class ProjectBasedTemplate < Redmine::Hook::ViewListener | 410 class ProjectBasedTemplate < Redmine::Hook::ViewListener |
728 def view_layouts_base_html_head(context) | 411 def view_layouts_base_html_head(context) |
729 # Adds a project stylesheet | 412 # Adds a project stylesheet |
730 stylesheet_link_tag(context[:project].identifier) if context[:project] | 413 stylesheet_link_tag(context[:project].identifier) if context[:project] |