From 896c89e71dcc19d742f8609ed7f81c765c399c8e Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 28 Aug 2018 16:19:01 +0100 Subject: Remove EE-specific code from Issuable --- app/models/concerns/issuable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 5f65fceb7af..7be890e5a25 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -109,8 +109,8 @@ module Issuable false end - def has_multiple_assignees? - assignees.count > 1 + def etag_caching_enabled? + false end end -- cgit v1.2.1 From 9357585ecacacfa0618b4f4172d5ea7dd0b1c5ae Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 29 Aug 2018 14:38:42 +0100 Subject: Remove EE-specific code from Mentionable --- app/models/concerns/mentionable.rb | 13 ++++++++++--- app/models/concerns/mentionable/reference_regexes.rb | 12 +++++++++--- app/models/epic.rb | 4 ++++ 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index 393607e82c4..298d0d42d90 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -61,7 +61,7 @@ module Mentionable cache_key: [self, attr], author: author, skip_project_check: skip_project_check? - ) + ).merge(mentionable_params) extractor.analyze(text, options) end @@ -86,12 +86,11 @@ module Mentionable return [] unless matches_cross_reference_regex? refs = all_references(current_user) - refs = (refs.issues + refs.merge_requests + refs.commits) # We're using this method instead of Array diffing because that requires # both of the object's `hash` values to be the same, which may not be the # case for otherwise identical Commit objects. - refs.reject { |ref| ref == local_reference } + extracted_mentionables(refs).reject { |ref| ref == local_reference } end # Uses regex to quickly determine if mentionables might be referenced @@ -134,6 +133,10 @@ module Mentionable private + def extracted_mentionables(refs) + refs.issues + refs.merge_requests + refs.commits + end + # Returns a Hash of changed mentionable fields # # Preference is given to the `changes` Hash, but falls back to @@ -161,4 +164,8 @@ module Mentionable def skip_project_check? false end + + def mentionable_params + {} + end end diff --git a/app/models/concerns/mentionable/reference_regexes.rb b/app/models/concerns/mentionable/reference_regexes.rb index f6fd28bac33..fe8fbb71184 100644 --- a/app/models/concerns/mentionable/reference_regexes.rb +++ b/app/models/concerns/mentionable/reference_regexes.rb @@ -5,13 +5,19 @@ module Mentionable def self.reference_pattern(link_patterns, issue_pattern) Regexp.union(link_patterns, issue_pattern, - Commit.reference_pattern, - MergeRequest.reference_pattern) + *other_patterns) + end + + def self.other_patterns + [ + Commit.reference_pattern, + MergeRequest.reference_pattern + ] end DEFAULT_PATTERN = begin issue_pattern = Issue.reference_pattern - link_patterns = Regexp.union([Issue, Commit, MergeRequest].map(&:link_reference_pattern)) + link_patterns = Regexp.union([Issue, Commit, MergeRequest, Epic].map(&:link_reference_pattern).compact) reference_pattern(link_patterns, issue_pattern) end diff --git a/app/models/epic.rb b/app/models/epic.rb index f027993376c..ccd10593434 100644 --- a/app/models/epic.rb +++ b/app/models/epic.rb @@ -3,6 +3,10 @@ # Placeholder class for model that is implemented in EE # It reserves '&' as a reference prefix, but the table does not exists in CE class Epic < ActiveRecord::Base + def self.link_reference_pattern + nil + end + def self.reference_prefix '&' end -- cgit v1.2.1 From b3cd850c3f47ab2527b13d5038abb99893a6bff9 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 28 Aug 2018 17:30:38 +0100 Subject: Remove EE-specific code from ProtectedRefAccess --- app/models/concerns/protected_ref_access.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/protected_ref_access.rb b/app/models/concerns/protected_ref_access.rb index efa666fb3f2..583751ea6ac 100644 --- a/app/models/concerns/protected_ref_access.rb +++ b/app/models/concerns/protected_ref_access.rb @@ -3,18 +3,22 @@ module ProtectedRefAccess extend ActiveSupport::Concern - ALLOWED_ACCESS_LEVELS = [ - Gitlab::Access::MAINTAINER, - Gitlab::Access::DEVELOPER, - Gitlab::Access::NO_ACCESS - ].freeze - HUMAN_ACCESS_LEVELS = { Gitlab::Access::MAINTAINER => "Maintainers".freeze, Gitlab::Access::DEVELOPER => "Developers + Maintainers".freeze, Gitlab::Access::NO_ACCESS => "No one".freeze }.freeze + class_methods do + def allowed_access_levels + [ + Gitlab::Access::MAINTAINER, + Gitlab::Access::DEVELOPER, + Gitlab::Access::NO_ACCESS + ] + end + end + included do scope :master, -> { maintainer } # @deprecated scope :maintainer, -> { where(access_level: Gitlab::Access::MAINTAINER) } @@ -26,7 +30,7 @@ module ProtectedRefAccess scope :for_group, -> { where.not(group_id: nil) } validates :access_level, presence: true, if: :role?, inclusion: { - in: ALLOWED_ACCESS_LEVELS + in: self.allowed_access_levels } end -- cgit v1.2.1 From 22d8f934ef2ca3ac57524f2345a016e2fe935799 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 17 Sep 2018 20:31:23 +0800 Subject: Fix bad conflicts resolution --- app/models/concerns/issuable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 7be890e5a25..5f65fceb7af 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -109,8 +109,8 @@ module Issuable false end - def etag_caching_enabled? - false + def has_multiple_assignees? + assignees.count > 1 end end -- cgit v1.2.1