From 388f52a0649391852c2b9980ce297e614aa15ec6 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 21 May 2020 11:51:37 +0200 Subject: [PATCH] Make a snapshot name synced with the inventory name if changed [SCI-4656] --- app/models/repository.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/repository.rb b/app/models/repository.rb index 2f2525115..c2e71d720 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -15,6 +15,8 @@ class Repository < RepositoryBase foreign_key: :parent_id, inverse_of: :original_repository + before_save :sync_name_with_snapshots, if: :name_changed? + validates :name, presence: true, uniqueness: { scope: :team_id, case_sensitive: false }, @@ -204,4 +206,10 @@ class Repository < RepositoryBase RepositorySnapshotProvisioningJob.perform_later(repository_snapshot) repository_snapshot end + + private + + def sync_name_with_snapshots + repository_snapshots.update(name: name) + end end