summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2019-08-27 15:11:15 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2019-08-27 15:11:15 +0000
commit75353242e2a2925fa968a3f9a5ad1db051a194cd (patch)
tree7d43a433da9ee80615f7ad40ca031d145825ff40
parent3cf15156229547c8283700cb3d035da8f7000be6 (diff)
downloadgitlab-ce-75353242e2a2925fa968a3f9a5ad1db051a194cd.tar.gz
Replace prepend_entity with prepend_if_ee
(cherry picked from commit 897a9d308db46b620b738b98f2b0e5630ac7d2dd)
-rw-r--r--config/initializers/0_inject_enterprise_edition_module.rb11
-rw-r--r--lib/api/entities.rb18
2 files changed, 27 insertions, 2 deletions
diff --git a/config/initializers/0_inject_enterprise_edition_module.rb b/config/initializers/0_inject_enterprise_edition_module.rb
index 39595e23abe..b3ebb44ef25 100644
--- a/config/initializers/0_inject_enterprise_edition_module.rb
+++ b/config/initializers/0_inject_enterprise_edition_module.rb
@@ -3,8 +3,15 @@
require 'active_support/inflector'
module InjectEnterpriseEditionModule
- def prepend_if_ee(constant)
- prepend(constant.constantize) if Gitlab.ee?
+ def prepend_if_ee(constant, with_descendants: false)
+ return unless Gitlab.ee?
+
+ ee_module = constant.constantize
+ prepend(ee_module)
+
+ if with_descendants
+ descendants.each { |descendant| descendant.prepend(ee_module) }
+ end
end
def extend_if_ee(constant)
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 5e66b4e76a5..6f86adf6a5c 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -1707,3 +1707,21 @@ module API
end
end
end
+
+# rubocop: disable Cop/InjectEnterpriseEditionModule
+API::Entities.prepend_if_ee('EE::API::Entities::Entities')
+::API::Entities::ApplicationSetting.prepend_if_ee('EE::API::Entities::ApplicationSetting')
+::API::Entities::Board.prepend_if_ee('EE::API::Entities::Board')
+::API::Entities::Group.prepend_if_ee('EE::API::Entities::Group', with_descendants: true)
+::API::Entities::GroupDetail.prepend_if_ee('EE::API::Entities::GroupDetail')
+::API::Entities::IssueBasic.prepend_if_ee('EE::API::Entities::IssueBasic', with_descendants: true)
+::API::Entities::List.prepend_if_ee('EE::API::Entities::List')
+::API::Entities::MergeRequestBasic.prepend_if_ee('EE::API::Entities::MergeRequestBasic', with_descendants: true)
+::API::Entities::Namespace.prepend_if_ee('EE::API::Entities::Namespace')
+::API::Entities::Project.prepend_if_ee('EE::API::Entities::Project', with_descendants: true)
+::API::Entities::ProtectedRefAccess.prepend_if_ee('EE::API::Entities::ProtectedRefAccess')
+::API::Entities::UserPublic.prepend_if_ee('EE::API::Entities::UserPublic', with_descendants: true)
+::API::Entities::Todo.prepend_if_ee('EE::API::Entities::Todo')
+::API::Entities::ProtectedBranch.prepend_if_ee('EE::API::Entities::ProtectedBranch')
+::API::Entities::Identity.prepend_if_ee('EE::API::Entities::Identity')
+::API::Entities::UserWithAdmin.prepend_if_ee('EE::API::Entities::UserWithAdmin', with_descendants: true)