Commit c6afc977 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

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

parent ab4bb67f
...@@ -45,7 +45,7 @@ describe Projects::BoardsController do ...@@ -45,7 +45,7 @@ describe Projects::BoardsController do
describe 'POST create' do describe 'POST create' do
context 'with the multiple issue boards available' do context 'with the multiple issue boards available' do
before do before do
stub_licensed_features(multiple_issue_boards: true) stub_licensed_features(multiple_project_issue_boards: true)
end end
context 'with valid params' do context 'with valid params' do
......
...@@ -12,7 +12,7 @@ describe 'label issues', :js do ...@@ -12,7 +12,7 @@ describe 'label issues', :js do
let!(:list) { create(:list, board: board, label: development, position: 0) } let!(:list) { create(:list, board: board, label: development, position: 0) }
before do before do
stub_licensed_features(group_issue_boards: true) stub_licensed_features(multiple_group_issue_boards: true)
group.add_maintainer(user) group.add_maintainer(user)
sign_in(user) sign_in(user)
......
...@@ -23,7 +23,7 @@ describe 'Scoped issue boards', :js do ...@@ -23,7 +23,7 @@ describe 'Scoped issue boards', :js do
before do before do
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true) 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 end
context 'user with edit permissions' do context 'user with edit permissions' do
...@@ -301,7 +301,7 @@ describe 'Scoped issue boards', :js do ...@@ -301,7 +301,7 @@ describe 'Scoped issue boards', :js do
context 'group board' do context 'group board' do
it 'only shows group labels in list' 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) visit group_boards_path(group)
edit_board.click edit_board.click
...@@ -419,7 +419,7 @@ describe 'Scoped issue boards', :js do ...@@ -419,7 +419,7 @@ describe 'Scoped issue boards', :js do
context 'with scoped_issue_boards feature disabled' do context 'with scoped_issue_boards feature disabled' do
before do before do
stub_licensed_features(scoped_issue_boards: false) stub_licensed_features(scoped_issue_board: false)
project.add_maintainer(user) project.add_maintainer(user)
login_as(user) login_as(user)
...@@ -441,7 +441,7 @@ describe 'Scoped issue boards', :js do ...@@ -441,7 +441,7 @@ describe 'Scoped issue boards', :js do
# To make sure the form is shown # To make sure the form is shown
expect(page).to have_field('board-new-name') expect(page).to have_field('board-new-name')
expect(page).not_to have_button('Toggle') expect(page).not_to have_button('Expand')
end end
end end
......
...@@ -9,6 +9,15 @@ module EE ...@@ -9,6 +9,15 @@ module EE
# This enables `geo` and disables `deploy_board` features for a spec. # This enables `geo` and disables `deploy_board` features for a spec.
# Other features are still enabled/disabled as defined in the license. # Other features are still enabled/disabled as defined in the license.
def stub_licensed_features(features) 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| 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