summaryrefslogtreecommitdiff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 13:26:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 13:26:31 +0000
commitb7dfe2ae4054aa40e15182fd3c6cb7dd39f131db (patch)
tree5ab080ca9cadeb6cd9578bf301e4e9e8810bed9e /app/models/concerns
parent25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff)
downloadgitlab-ce-b7dfe2ae4054aa40e15182fd3c6cb7dd39f131db.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/issuable.rb3
-rw-r--r--app/models/concerns/mentionable.rb2
-rw-r--r--app/models/concerns/mentionable/reference_regexes.rb2
-rw-r--r--app/models/concerns/noteable.rb3
-rw-r--r--app/models/concerns/participable.rb3
-rw-r--r--app/models/concerns/prometheus_adapter.rb2
-rw-r--r--app/models/concerns/protected_ref.rb6
-rw-r--r--app/models/concerns/protected_ref_access.rb11
-rw-r--r--app/models/concerns/sha_attribute.rb2
9 files changed, 32 insertions, 2 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index a998d9b7e1b..d02f3731cc2 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -439,3 +439,6 @@ module Issuable
respond_to?(:milestone_id)
end
end
+
+Issuable.prepend_if_ee('EE::Issuable') # rubocop: disable Cop/InjectEnterpriseEditionModule
+Issuable::ClassMethods.prepend_if_ee('EE::Issuable::ClassMethods')
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 2f3f9b399d9..377600ef6e5 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -172,3 +172,5 @@ module Mentionable
{}
end
end
+
+Mentionable.prepend_if_ee('EE::Mentionable')
diff --git a/app/models/concerns/mentionable/reference_regexes.rb b/app/models/concerns/mentionable/reference_regexes.rb
index b8fb3f71925..fec31cd262b 100644
--- a/app/models/concerns/mentionable/reference_regexes.rb
+++ b/app/models/concerns/mentionable/reference_regexes.rb
@@ -34,3 +34,5 @@ module Mentionable
end
end
end
+
+Mentionable::ReferenceRegexes.prepend_if_ee('EE::Mentionable::ReferenceRegexes')
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb
index b3e4df730b4..6caa23ef9b7 100644
--- a/app/models/concerns/noteable.rb
+++ b/app/models/concerns/noteable.rb
@@ -143,3 +143,6 @@ module Noteable
end
Noteable.extend(Noteable::ClassMethods)
+
+Noteable::ClassMethods.prepend_if_ee('EE::Noteable::ClassMethods') # rubocop: disable Cop/InjectEnterpriseEditionModule
+Noteable.prepend_if_ee('EE::Noteable')
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index b140fca9b83..af105629398 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -25,7 +25,6 @@
# users = issue.participants
module Participable
extend ActiveSupport::Concern
-
class_methods do
# Adds a list of participant attributes. Attributes can either be symbols or
# Procs.
@@ -112,3 +111,5 @@ module Participable
end
end
end
+
+Participable.prepend_if_ee('EE::Participable')
diff --git a/app/models/concerns/prometheus_adapter.rb b/app/models/concerns/prometheus_adapter.rb
index 9ac4722c6b1..aab0589f7ca 100644
--- a/app/models/concerns/prometheus_adapter.rb
+++ b/app/models/concerns/prometheus_adapter.rb
@@ -5,6 +5,8 @@ module PrometheusAdapter
included do
include ReactiveCaching
+ # We can't prepend outside of this model due to the use of `included`, so this must stay here.
+ prepend_if_ee('EE::PrometheusAdapter') # rubocop: disable Cop/InjectEnterpriseEditionModule
self.reactive_cache_lease_timeout = 30.seconds
self.reactive_cache_refresh_interval = 30.seconds
diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb
index 0648b4a78e1..ebacc459cb5 100644
--- a/app/models/concerns/protected_ref.rb
+++ b/app/models/concerns/protected_ref.rb
@@ -67,3 +67,9 @@ module ProtectedRef
@ref_matcher ||= RefMatcher.new(self.name)
end
end
+
+# Prepending a module into a concern doesn't work very well for class methods,
+# since these are defined in a ClassMethods constant. As such, we prepend the
+# module directly into ProtectedRef::ClassMethods, instead of prepending it into
+# ProtectedRef.
+ProtectedRef::ClassMethods.prepend_if_ee('EE::ProtectedRef')
diff --git a/app/models/concerns/protected_ref_access.rb b/app/models/concerns/protected_ref_access.rb
index 208937f2aff..01cb5a14762 100644
--- a/app/models/concerns/protected_ref_access.rb
+++ b/app/models/concerns/protected_ref_access.rb
@@ -2,7 +2,6 @@
module ProtectedRefAccess
extend ActiveSupport::Concern
-
HUMAN_ACCESS_LEVELS = {
Gitlab::Access::MAINTAINER => "Maintainers",
Gitlab::Access::DEVELOPER => "Developers + Maintainers",
@@ -51,3 +50,13 @@ module ProtectedRefAccess
project.team.max_member_access(user.id) >= access_level
end
end
+
+ProtectedRefAccess.include_if_ee('EE::ProtectedRefAccess::Scopes') # rubocop: disable Cop/InjectEnterpriseEditionModule
+ProtectedRefAccess.prepend_if_ee('EE::ProtectedRefAccess') # rubocop: disable Cop/InjectEnterpriseEditionModule
+
+# When using `prepend` (or `include` for that matter), the `ClassMethods`
+# constants are not merged. This means that `class_methods` in
+# `EE::ProtectedRefAccess` would be ignored.
+#
+# To work around this, we prepend the `ClassMethods` constant manually.
+ProtectedRefAccess::ClassMethods.prepend_if_ee('EE::ProtectedRefAccess::ClassMethods')
diff --git a/app/models/concerns/sha_attribute.rb b/app/models/concerns/sha_attribute.rb
index 70ac873a030..177004deba6 100644
--- a/app/models/concerns/sha_attribute.rb
+++ b/app/models/concerns/sha_attribute.rb
@@ -47,3 +47,5 @@ module ShaAttribute
end
end
end
+
+ShaAttribute::ClassMethods.prepend_if_ee('EE::ShaAttribute')