Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/packages/tag.rb')
-rw-r--r--app/models/packages/tag.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/packages/tag.rb b/app/models/packages/tag.rb
index 9c17a147bf4..0df64bfba54 100644
--- a/app/models/packages/tag.rb
+++ b/app/models/packages/tag.rb
@@ -1,9 +1,12 @@
# frozen_string_literal: true
class Packages::Tag < ApplicationRecord
belongs_to :package, inverse_of: :tags
+ belongs_to :project
validates :package, :name, presence: true
+ before_save :ensure_project_id
+
FOR_PACKAGES_TAGS_LIMIT = 200
NUGET_TAGS_SEPARATOR = ' ' # https://docs.microsoft.com/en-us/nuget/reference/nuspec#tags
@@ -15,4 +18,8 @@ class Packages::Tag < ApplicationRecord
.order(updated_at: :desc)
.limit(FOR_PACKAGES_TAGS_LIMIT)
end
+
+ def ensure_project_id
+ self.project_id ||= package.project_id
+ end
end