mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-20 23:41:12 +00:00
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
This commit is contained in:
parent
4fdac0655a
commit
75b3e88cee
@ -24,7 +24,7 @@ class Enumeration < ActiveRecord::Base
|
|||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
acts_as_positioned :scope => :parent_id
|
acts_as_positioned :scope => %i[project_id parent_id]
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
acts_as_tree
|
acts_as_tree
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class Enumeration < ActiveRecord::Base
|
|||||||
# position as the overridden enumeration
|
# position as the overridden enumeration
|
||||||
def update_position
|
def update_position
|
||||||
super
|
super
|
||||||
if saved_change_to_position?
|
if saved_change_to_position? && self.parent_id.nil?
|
||||||
self.class.where.not(:parent_id => nil).update_all(
|
self.class.where.not(:parent_id => nil).update_all(
|
||||||
"position = coalesce((
|
"position = coalesce((
|
||||||
select position
|
select position
|
||||||
|
|||||||
@ -131,4 +131,24 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
|
|||||||
assert_include activity, project.activities
|
assert_include activity, project.activities
|
||||||
assert_include TimeEntryActivity.find(9), project.activities
|
assert_include TimeEntryActivity.find(9), project.activities
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user