Commit 7914849d authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename `extend_if_ee` to `extend_mod_with`

parent 52685fea
......@@ -442,4 +442,4 @@ ApplicationSettingsHelper.prepend_mod_with('EE::ApplicationSettingsHelper')
# The methods in `EE::ApplicationSettingsHelper` should be available as both
# instance and class methods.
ApplicationSettingsHelper.extend_if_ee('EE::ApplicationSettingsHelper')
ApplicationSettingsHelper.extend_mod_with('EE::ApplicationSettingsHelper')
......@@ -195,4 +195,4 @@ AuthHelper.prepend_mod_with('EE::AuthHelper')
# The methods added in EE should be available as both class and instance
# methods, just like the methods provided by `AuthHelper` itself.
AuthHelper.extend_if_ee('EE::AuthHelper')
AuthHelper.extend_mod_with('EE::AuthHelper')
......@@ -182,4 +182,4 @@ ServicesHelper.prepend_mod_with('EE::ServicesHelper')
# The methods in `EE::ServicesHelper` should be available as both instance and
# class methods.
ServicesHelper.extend_if_ee('EE::ServicesHelper')
ServicesHelper.extend_mod_with('EE::ServicesHelper')
......@@ -58,4 +58,4 @@ SystemNoteHelper.prepend_mod_with('EE::SystemNoteHelper')
# The methods in `EE::SystemNoteHelper` should be available as both instance and
# class methods.
SystemNoteHelper.extend_if_ee('EE::SystemNoteHelper')
SystemNoteHelper.extend_mod_with('EE::SystemNoteHelper')
......@@ -10,7 +10,7 @@ module InjectEnterpriseEditionModule
with_descendants: with_descendants)
end
def extend_if_ee(constant_with_prefix, namespace: Object)
def extend_mod_with(constant_with_prefix, namespace: Object)
each_extension_for(
constant_without_prefix(constant_with_prefix),
namespace,
......
......@@ -114,7 +114,7 @@ Vulnerabilities::Finding.prepend_ee_mod
will prepend the module named `::EE::Vulnerabilities::Finding`.
If the extending module does not follow this naming convention, you can also provide the module name
by using `prepend_mod_with`, `extend_if_ee`, or `include_if_ee`. These methods take a
by using `prepend_mod_with`, `extend_mod_with`, or `include_if_ee`. These methods take a
_String_ containing the full module name as the argument, not the module itself, like so;
```ruby
......
......@@ -13,7 +13,7 @@ module EE
# ::SystemNoteService wants the methods to be available as both class and
# instance methods. This removes the need for having to both `include` and
# `extend` this module everywhere it is used.
extend_if_ee('EE::SystemNoteService') # rubocop: disable Cop/InjectEnterpriseEditionModule
extend_mod_with('EE::SystemNoteService') # rubocop: disable Cop/InjectEnterpriseEditionModule
end
def epic_issue(epic, issue, user, type)
......
......@@ -403,4 +403,4 @@ module QA
end
end
QA::Runtime::Env.extend_if_ee('Runtime::Env', namespace: QA)
QA::Runtime::Env.extend_mod_with('Runtime::Env', namespace: QA)
......@@ -9,12 +9,12 @@ module RuboCop
', outside of any class or module definitions'
DISALLOWED_METHOD =
'EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`'
'EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`'
INVALID_ARGUMENT = 'EE modules to inject must be specified as a String'
CHECK_LINE_METHODS =
Set.new(%i[include_if_ee extend_if_ee prepend_mod_with]).freeze
Set.new(%i[include_if_ee extend_mod_with prepend_mod_with]).freeze
DISALLOW_METHODS = Set.new(%i[include extend prepend]).freeze
......
......@@ -119,7 +119,7 @@ RSpec.describe InjectEnterpriseEditionModule do
it_behaves_like 'expand the extension with', :prepend
end
describe '#extend_if_ee' do
describe '#extend_mod_with' do
it_behaves_like 'expand the extension with', :extend
end
......
......@@ -86,19 +86,19 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE
end
it 'flags the use of `extend_if_ee EE` in the middle of a file' do
it 'flags the use of `extend_mod_with EE` in the middle of a file' do
expect_offense(<<~SOURCE)
class Foo
extend_if_ee 'EE::Foo'
extend_mod_with 'EE::Foo'
^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
end
SOURCE
end
it 'flags the use of `extend_if_ee ::EE` in the middle of a file' do
it 'flags the use of `extend_mod_with ::EE` in the middle of a file' do
expect_offense(<<~SOURCE)
class Foo
extend_if_ee '::EE::Foo'
extend_mod_with '::EE::Foo'
^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
end
SOURCE
......@@ -123,7 +123,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
it 'does not flag extending using regular modules' do
expect_no_offenses(<<~SOURCE)
class Foo
extend_if_ee 'Foo'
extend_mod_with 'Foo'
end
SOURCE
end
......@@ -146,12 +146,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE
end
it 'does not flag the use of `extend_if_ee EE` on the last line' do
it 'does not flag the use of `extend_mod_with EE` on the last line' do
expect_no_offenses(<<~SOURCE)
class Foo
end
Foo.extend_if_ee('EE::Foo')
Foo.extend_mod_with('EE::Foo')
SOURCE
end
......@@ -160,7 +160,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
class Foo
end
Foo.extend_if_ee('EE::Foo')
Foo.extend_mod_with('EE::Foo')
Foo.include_if_ee('EE::Foo')
Foo.prepend_mod_with('EE::Foo')
SOURCE
......@@ -203,7 +203,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.prepend(EE::Foo)
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
......@@ -213,7 +213,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.prepend(QA::EE::Foo)
^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`
^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
......@@ -223,7 +223,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.extend(EE::Foo)
^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`
^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
......@@ -233,7 +233,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end
Foo.include(EE::Foo)
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE
end
......@@ -257,12 +257,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE
end
it 'disallows the use of extend_if_ee without a String' do
it 'disallows the use of extend_mod_with without a String' do
expect_offense(<<~SOURCE)
class Foo
end
Foo.extend_if_ee(EE::Foo)
Foo.extend_mod_with(EE::Foo)
^^^^^^^ EE modules to inject must be specified as a String
SOURCE
end
......
......@@ -613,4 +613,4 @@ end
require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee?
::TestEnv.prepend_mod_with('::EE::TestEnv')
::TestEnv.extend_if_ee('::EE::TestEnv')
::TestEnv.extend_mod_with('::EE::TestEnv')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment