diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-09 06:09:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-09 06:09:18 +0300 |
commit | 9c8d620e48c59fe3d10f9c4b50f91124d7c09182 (patch) | |
tree | c629ebcedd29c2ca756af2367218f6723ac3d58d /app/models/operations | |
parent | 1c0289261b8d67e983b5d3ed1ef23fd800deab98 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/operations')
-rw-r--r-- | app/models/operations/feature_flag.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/operations/feature_flag.rb b/app/models/operations/feature_flag.rb index 442f9d36c43..be3f719ddb3 100644 --- a/app/models/operations/feature_flag.rb +++ b/app/models/operations/feature_flag.rb @@ -6,6 +6,7 @@ module Operations include AtomicInternalId include IidRoutes include Limitable + include Referable self.table_name = 'operations_feature_flags' self.limit_scope = :project @@ -65,6 +66,31 @@ module Operations .reorder(:id) .references(:operations_scopes) end + + def reference_prefix + '[feature_flag:' + end + + def reference_pattern + @reference_pattern ||= %r{ + #{Regexp.escape(reference_prefix)}(#{::Project.reference_pattern}\/)?(?<feature_flag>\d+)#{Regexp.escape(reference_postfix)} + }x + end + + def link_reference_pattern + @link_reference_pattern ||= super("feature_flags", /(?<feature_flag>\d+)\/edit/) + end + + def reference_postfix + ']' + end + end + + def to_reference(from = nil, full: false) + project + .to_reference_base(from, full: full) + .then { |reference_base| reference_base.present? ? "#{reference_base}/" : nil } + .then { |reference_base| "#{self.class.reference_prefix}#{reference_base}#{iid}#{self.class.reference_postfix}" } end def related_issues(current_user, preload:) |