Commit 7d754c29 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ee-6539-extract-ee-specific-code' into 'master'

Port Add no-op license helper to CE

See merge request gitlab-org/gitlab-ee!10485
parents 3ea2cfa3 bc4a8443
module EE
module LicenseHelpers
extend ActiveSupport::Concern
# Enable/Disable a feature on the License for a spec.
#
# Example:
......@@ -8,26 +10,29 @@ module EE
#
# This enables `geo` and disables `deploy_board` features for a spec.
# Other features are still enabled/disabled as defined in the license.
def stub_licensed_features(features)
existing_features = License::FEATURES_BY_PLAN.values.flatten.map(&:to_sym)
missing_features = features.keys.map(&:to_sym) - existing_features
if missing_features.any?
subject = missing_features.join(', ')
noun = 'feature'.pluralize(missing_features.size)
raise ArgumentError, "#{subject} should be defined as licensed #{noun}"
end
prepended do
def stub_licensed_features(features)
existing_features = License::FEATURES_BY_PLAN.values.flatten.map(&:to_sym)
missing_features = features.keys.map(&:to_sym) - existing_features
if missing_features.any?
subject = missing_features.join(', ')
noun = 'feature'.pluralize(missing_features.size)
raise ArgumentError, "#{subject} should be defined as licensed #{noun}"
end
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).and_call_original
features.each do |feature, enabled|
allow(License).to receive(:feature_available?).with(feature) { enabled }
features.each do |feature, enabled|
allow(License).to receive(:feature_available?).with(feature) { enabled }
end
end
end
def enable_namespace_license_check!
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
::Gitlab::CurrentSettings.update!(check_namespace_plan: true)
def enable_namespace_license_check!
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
::Gitlab::CurrentSettings.update!(check_namespace_plan: true)
end
end
end
end
......@@ -16,7 +16,6 @@ describe QuickActions::InterpretService do
before do
stub_licensed_features(multiple_issue_assignees: false)
project.add_developer(developer)
end
......
......@@ -68,6 +68,7 @@ RSpec.configure do |config|
metadata[:type] = match[1].singularize.to_sym if match
end
config.include LicenseHelpers
config.include ActiveJob::TestHelper
config.include ActiveSupport::Testing::TimeHelpers
config.include CycleAnalyticsHelpers
......
# frozen_string_literal: true
# Placeholder module for EE implementation needed for CE specs to be run in EE codebase
module LicenseHelpers
def stub_licensed_features(features)
# do nothing
end
end
LicenseHelpers.prepend(EE::LicenseHelpers)
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