Merge pull request #2591 from okriuchykhin/ok_SCI_4656

Make a snapshot name synced with the inventory name if changed [SCI-4656]
This commit is contained in:
Miha Mencin 2020-05-22 12:57:08 +02:00 committed by GitHub
commit a4cd014682
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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