diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-05-01 17:10:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-05-01 17:10:15 +0000 |
commit | c5ac2d3966c2ac04a2580fca67a40acf24b51239 (patch) | |
tree | 45f8eca2133899ea2bd8fd4841e14adb4709fc85 /test/unit/time_entry_activity_test.rb | |
parent | 6c39a260a3c44c1d121a7421b1d6c09358da20a1 (diff) | |
download | redmine-c5ac2d3966c2ac04a2580fca67a40acf24b51239.tar.gz redmine-c5ac2d3966c2ac04a2580fca67a40acf24b51239.zip |
Fixed that deleting a system activity with children in use raises an error (#13783).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11763 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/time_entry_activity_test.rb')
-rw-r--r-- | test/unit/time_entry_activity_test.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/unit/time_entry_activity_test.rb b/test/unit/time_entry_activity_test.rb index 3a7547415..a094c84ca 100644 --- a/test/unit/time_entry_activity_test.rb +++ b/test/unit/time_entry_activity_test.rb @@ -84,5 +84,33 @@ class TimeEntryActivityTest < ActiveSupport::TestCase e.reload assert_equal "0", e.custom_value_for(field).value end -end + def test_system_activity_with_child_in_use_should_be_in_use + project = Project.generate! + system_activity = TimeEntryActivity.create!(:name => 'Activity') + project_activity = TimeEntryActivity.create!(:name => 'Activity', :project => project, :parent_id => system_activity.id) + + TimeEntry.generate!(:project => project, :activity => project_activity) + + assert project_activity.in_use? + assert system_activity.in_use? + end + + def test_destroying_a_system_activity_should_reassign_children_activities + project = Project.generate! + system_activity = TimeEntryActivity.create!(:name => 'Activity') + project_activity = TimeEntryActivity.create!(:name => 'Activity', :project => project, :parent_id => system_activity.id) + + entries = [ + TimeEntry.generate!(:project => project, :activity => system_activity), + TimeEntry.generate!(:project => project, :activity => project_activity) + ] + + assert_difference 'TimeEntryActivity.count', -2 do + assert_nothing_raised do + assert system_activity.destroy(TimeEntryActivity.find_by_name('Development')) + end + end + assert entries.all? {|entry| entry.reload.activity.name == 'Development'} + end +end |