diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-07-23 16:51:13 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-07-30 14:52:54 +0200 |
commit | 916183a7fd63f772a8493c9ac782b465503f9d13 (patch) | |
tree | 7835e5e3e0c3b8b63be81b7f44e5221cd0770e0e | |
parent | 5a221665bedc2366b30b2a2b0f777ead657c6143 (diff) | |
download | gitlab-ce-916183a7fd63f772a8493c9ac782b465503f9d13.tar.gz |
Add methods for injecting EE modules
This adds the methods prepend_if_ee, extend_if_ee, and include_if_ee
that can be used to inject EE specific modules in EE.
These methods are exposed as an initializer that is loaded as soon as
possible. For tests that use fast_spec_helper.rb we must load this
initializer manually, as the Rails environment is not loaded. This is
not the most pretty setup, but unfortunately there is no alternative
that we can use.
-rw-r--r-- | config/initializers/0_inject_enterprise_edition_module.rb | 17 | ||||
-rw-r--r-- | spec/fast_spec_helper.rb | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/config/initializers/0_inject_enterprise_edition_module.rb b/config/initializers/0_inject_enterprise_edition_module.rb new file mode 100644 index 00000000000..4b21732e179 --- /dev/null +++ b/config/initializers/0_inject_enterprise_edition_module.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module InjectEnterpriseEditionModule + def prepend_if_ee(constant) + prepend(constant.constantize) if Gitlab.ee? + end + + def extend_if_ee(constant) + extend(constant.constantize) if Gitlab.ee? + end + + def include_if_ee(constant) + include(constant.constantize) if Gitlab.ee? + end +end + +Module.prepend(InjectEnterpriseEditionModule) diff --git a/spec/fast_spec_helper.rb b/spec/fast_spec_helper.rb index 91ef7653822..f5a487b4d57 100644 --- a/spec/fast_spec_helper.rb +++ b/spec/fast_spec_helper.rb @@ -4,6 +4,7 @@ ENV['GITLAB_ENV'] = 'test' ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true' require 'active_support/dependencies' +require_relative '../config/initializers/0_inject_enterprise_edition_module' require_relative '../config/settings' require_relative 'support/rspec' require 'active_support/all' |