mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-03 23:53:23 +00:00
Project specific TimeEntryActivity name not updating properly (#21056).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@21054 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e13660e308
commit
9101dcf111
@ -30,6 +30,7 @@ class Enumeration < ActiveRecord::Base
|
||||
|
||||
before_destroy :check_integrity
|
||||
before_save :check_default
|
||||
after_save :update_children_name
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :scope => [:type, :project_id], :case_sensitive => true
|
||||
@ -136,6 +137,12 @@ class Enumeration < ActiveRecord::Base
|
||||
raise "Cannot delete enumeration" if self.in_use?
|
||||
end
|
||||
|
||||
def update_children_name
|
||||
if saved_change_to_name? && self.parent_id.nil?
|
||||
self.class.where(name: self.name_before_last_save, parent_id: self.id).update_all(name: self.name_in_database)
|
||||
end
|
||||
end
|
||||
|
||||
# Overrides Redmine::Acts::Positioned#set_default_position so that enumeration overrides
|
||||
# get the same position as the overridden enumeration
|
||||
def set_default_position
|
||||
|
||||
@ -170,4 +170,30 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
|
||||
assert_equal 3, other_parent_activity.reload.position
|
||||
assert_equal other_parent_activity.position, other_project_activity.reload.position
|
||||
end
|
||||
|
||||
def test_project_activity_should_have_the_same_name_as_parent_activity
|
||||
parent_activity = TimeEntryActivity.find_by(name: 'Design', parent_id: nil)
|
||||
project = Project.find(1)
|
||||
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(name: 'Design', parent_id: parent_activity.id, project_id: project.id)
|
||||
assert_equal parent_activity.name, project_activity.name
|
||||
|
||||
parent_activity.update(name: 'Design1')
|
||||
assert_equal parent_activity.reload.name, project_activity.reload.name
|
||||
|
||||
# When changing the name of parent_activity,
|
||||
# if the name of parent_activity before the change and the name of project_activity do not match, the name of project_activity is not changed.
|
||||
project_activity.update(name: 'Design2')
|
||||
parent_activity.update(name: 'Design3')
|
||||
assert_equal 'Design2', project_activity.reload.name
|
||||
assert_equal 'Design3', parent_activity.reload.name
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user