Commit 1bf769a3 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'osw-stub-feature-method-raise-error' into 'master'

Raise error when stubbing a feature that is not defined on license.rb

See merge request gitlab-org/gitlab-ee!6691
parents da555873 c6afc977
......@@ -45,7 +45,7 @@ describe Projects::BoardsController do
describe 'POST create' do
context 'with the multiple issue boards available' do
before do
stub_licensed_features(multiple_issue_boards: true)
stub_licensed_features(multiple_project_issue_boards: true)
end
context 'with valid params' do
......
......@@ -12,7 +12,7 @@ describe 'label issues', :js do
let!(:list) { create(:list, board: board, label: development, position: 0) }
before do
stub_licensed_features(group_issue_boards: true)
stub_licensed_features(multiple_group_issue_boards: true)
group.add_maintainer(user)
sign_in(user)
......
......@@ -23,7 +23,7 @@ describe 'Scoped issue boards', :js do
before do
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true)
stub_licensed_features(scoped_issue_boards: true)
stub_licensed_features(scoped_issue_board: true)
end
context 'user with edit permissions' do
......@@ -301,7 +301,7 @@ describe 'Scoped issue boards', :js do
context 'group board' do
it 'only shows group labels in list' do
stub_licensed_features(group_issue_boards: true)
stub_licensed_features(multiple_group_issue_boards: true)
visit group_boards_path(group)
edit_board.click
......@@ -419,7 +419,7 @@ describe 'Scoped issue boards', :js do
context 'with scoped_issue_boards feature disabled' do
before do
stub_licensed_features(scoped_issue_boards: false)
stub_licensed_features(scoped_issue_board: false)
project.add_maintainer(user)
login_as(user)
......@@ -441,7 +441,7 @@ describe 'Scoped issue boards', :js do
# To make sure the form is shown
expect(page).to have_field('board-new-name')
expect(page).not_to have_button('Toggle')
expect(page).not_to have_button('Expand')
end
end
......
......@@ -9,6 +9,15 @@ 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
allow(License).to receive(:feature_available?).and_call_original
features.each do |feature, enabled|
......
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