diff options
author | Go MAEDA <maeda@farend.jp> | 2020-09-22 07:50:46 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-09-22 07:50:46 +0000 |
commit | 75b3e88cee997a3e24c406553b87eb43c82efe97 (patch) | |
tree | 34d93d2d52cd8d25548640d2d6f920779b403575 /test/unit | |
parent | 4fdac0655ab808955abdbf69ae31ed337f8c7738 (diff) | |
download | redmine-75b3e88cee997a3e24c406553b87eb43c82efe97.tar.gz redmine-75b3e88cee997a3e24c406553b87eb43c82efe97.zip |
Fix that updating time tracking activities in a project may take a long time (#33289).
Patch by Mizuki ISHIKAWA.
git-svn-id: http://svn.redmine.org/redmine/trunk@20066 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/time_entry_activity_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/time_entry_activity_test.rb b/test/unit/time_entry_activity_test.rb index 9a338b4ce..c1a081d48 100644 --- a/test/unit/time_entry_activity_test.rb +++ b/test/unit/time_entry_activity_test.rb @@ -131,4 +131,24 @@ class TimeEntryActivityTest < ActiveSupport::TestCase assert_include activity, project.activities assert_include TimeEntryActivity.find(9), project.activities end + + def test_project_activity_should_have_the_same_position_as_parent_activity + project = Project.find(1) + + parent_activity = TimeEntryActivity.find_by(position: 3, parent_id: nil) + project.update_or_create_time_entry_activities({parent_activity.id.to_s => {'parent_id' => parent_activity.id.to_s, 'active' => '0', 'custom_field_values' => {'7' => ''}}}) + project_activity = TimeEntryActivity.find_by(position: 3, parent_id: parent_activity.id, project_id: 1) + assert_equal parent_activity.position, project_activity.position + + # Changing the position of the parent activity also changes the position of the activity in each project. + other_parent_activity = TimeEntryActivity.find_by(position: 4, parent_id: nil) + project.update_or_create_time_entry_activities({other_parent_activity.id.to_s => {'parent_id' => other_parent_activity.id.to_s, 'active' => '0', 'custom_field_values' => {'7' => ''}}}) + other_project_activity = TimeEntryActivity.find_by(position: 4, parent_id: other_parent_activity.id, project_id: 1) + + parent_activity.update(position: 4) + assert_equal 4, parent_activity.reload.position + assert_equal parent_activity.position, project_activity.reload.position + assert_equal 3, other_parent_activity.reload.position + assert_equal other_parent_activity.position, other_project_activity.reload.position + end end |