Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove enterprise_token_helper.rb and the with_enterprise_token method

Dombi Attila5fa819a54b25
diff --git a/modules/auth_plugins/spec/requests/auth_plugins_spec.rb b/modules/auth_plugins/spec/requests/auth_plugins_spec.rb
index 4cccdd434e4..022b6558cce 100644
--- a/modules/auth_plugins/spec/requests/auth_plugins_spec.rb
+++ b/modules/auth_plugins/spec/requests/auth_plugins_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require 'open_project/auth_plugins'
-describe OpenProject::Plugins::AuthPlugin do
+describe OpenProject::Plugins::AuthPlugin, with_ee: %i[board_view] do
let(:dummy_engine_klass) do
Class.new { extend OpenProject::Plugins::AuthPlugin }
end
@@ -47,7 +47,6 @@ describe OpenProject::Plugins::AuthPlugin do
let(:middlewares) { [] }
before do
- with_enterprise_token :board_view
app = Object.new
omniauth_builder = Object.new
diff --git a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
index cae99e2e108..d0104940266 100644
--- a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
+++ b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require 'rack/test'
-describe 'SAML provider callback' do
+describe 'SAML provider callback', with_ee: %i[openid_providers] do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -74,7 +74,6 @@ describe 'SAML provider callback' do
end
before do
- with_enterprise_token :openid_providers
Setting.plugin_openproject_auth_saml = {
"providers" => { "saml" => config }
}
diff --git a/modules/boards/spec/features/action_boards/assignee_board_spec.rb b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
index a1490c0d932..1c03ac1a34c 100644
--- a/modules/boards/spec/features/action_boards/assignee_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
@@ -31,7 +31,8 @@ require_relative './../support/board_index_page'
require_relative './../support/board_page'
describe 'Assignee action board',
- js: true do
+ js: true,
+ with_ee: %i[board_view] do
let(:bobself_user) do
create(:user,
firstname: 'Bob',
@@ -83,7 +84,6 @@ describe 'Assignee action board',
context 'in a project with members' do
before do
- with_enterprise_token :board_view
login_as(bobself_user)
end
@@ -189,7 +189,6 @@ describe 'Assignee action board',
context 'in a project without members' do
before do
- with_enterprise_token :board_view
login_as(admin)
end
diff --git a/modules/boards/spec/features/action_boards/custom_field_filters_spec.rb b/modules/boards/spec/features/action_boards/custom_field_filters_spec.rb
index b9071a2221d..201186890c2 100644
--- a/modules/boards/spec/features/action_boards/custom_field_filters_spec.rb
+++ b/modules/boards/spec/features/action_boards/custom_field_filters_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './../support//board_index_page'
require_relative './../support/board_page'
-describe 'Custom field filter in boards', js: true do
+describe 'Custom field filter in boards', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -84,7 +84,6 @@ describe 'Custom field filter in boards', js: true do
end
before do
- with_enterprise_token :board_view
project
login_as(user)
end
diff --git a/modules/boards/spec/features/action_boards/status_board_spec.rb b/modules/boards/spec/features/action_boards/status_board_spec.rb
index 1547cc9beca..a18e2f74ac6 100644
--- a/modules/boards/spec/features/action_boards/status_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/status_board_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './../support//board_index_page'
require_relative './../support/board_page'
-describe 'Status action board', js: true do
+describe 'Status action board', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -78,7 +78,6 @@ describe 'Status action board', js: true do
end
before do
- with_enterprise_token :board_view
project
login_as(user)
end
@@ -145,7 +144,7 @@ describe 'Status action board', js: true do
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :status_id)
- expect(subjects).to match_array [['Task 1', open_status.id]]
+ expect(subjects).to contain_exactly(['Task 1', open_status.id])
# Move item to Closed
board_page.move_card(0, from: 'Open', to: 'Closed')
@@ -160,7 +159,7 @@ describe 'Status action board', js: true do
end
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :status_id)
- expect(subjects).to match_array [['Task 1', closed_status.id]]
+ expect(subjects).to contain_exactly(['Task 1', closed_status.id])
# Try to drag to whatever, which has no workflow
board_page.move_card(0, from: 'Closed', to: 'Whatever')
@@ -220,7 +219,7 @@ describe 'Status action board', js: true do
expect(queries.first.ordered_work_packages).to be_empty
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id))
- expect(subjects.pluck(:subject, :status_id)).to match_array [['Task 1', closed_status.id]]
+ expect(subjects.pluck(:subject, :status_id)).to contain_exactly(['Task 1', closed_status.id])
# Open remaining in split view
wp = second.ordered_work_packages.first.work_package
diff --git a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
index 24d18f3715d..e55ff24ea4c 100644
--- a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './../support//board_index_page'
require_relative './../support/board_page'
-describe 'Status action board', js: true do
+describe 'Status action board', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -102,7 +102,6 @@ describe 'Status action board', js: true do
let(:filters) { Components::WorkPackages::Filters.new }
before do
- with_enterprise_token :board_view
task_wp
bug_wp
login_as(user)
diff --git a/modules/boards/spec/features/action_boards/subproject_board_spec.rb b/modules/boards/spec/features/action_boards/subproject_board_spec.rb
index 8ac7d10fb35..6c21b15f5af 100644
--- a/modules/boards/spec/features/action_boards/subproject_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/subproject_board_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './../support//board_index_page'
require_relative './../support/board_page'
-describe 'Subproject action board', js: true do
+describe 'Subproject action board', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -60,7 +60,6 @@ describe 'Subproject action board', js: true do
let!(:work_package) { create(:work_package, project: subproject1, subject: 'Foo', status: open_status) }
before do
- with_enterprise_token :board_view
subproject1
subproject2
project.reload
@@ -156,7 +155,7 @@ describe 'Subproject action board', js: true do
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :project_id)
- expect(subjects).to match_array [['Task 1', subproject1.id]]
+ expect(subjects).to contain_exactly(['Task 1', subproject1.id])
# Move item to Child 2 list
board_page.move_card(0, from: 'Child 1', to: 'Child 2')
@@ -171,7 +170,7 @@ describe 'Subproject action board', js: true do
end
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :project_id)
- expect(subjects).to match_array [['Task 1', subproject2.id]]
+ expect(subjects).to contain_exactly(['Task 1', subproject2.id])
end
end
@@ -212,7 +211,7 @@ describe 'Subproject action board', js: true do
board_page.expect_no_list(subproject2.name)
expect(page)
- .to have_no_content invisible_work_package.subject
+ .not_to have_content invisible_work_package.subject
end
end
diff --git a/modules/boards/spec/features/action_boards/subtasks_board_spec.rb b/modules/boards/spec/features/action_boards/subtasks_board_spec.rb
index 6d9d8bb443a..e9b648a118c 100644
--- a/modules/boards/spec/features/action_boards/subtasks_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/subtasks_board_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './../support//board_index_page'
require_relative './../support/board_page'
-describe 'Subtasks action board', js: true do
+describe 'Subtasks action board', js: true, with_ee: %i[board_view] do
let(:type) { create(:type_standard) }
let(:project) { create(:project, types: [type], enabled_module_names: %i[work_package_tracking board_view]) }
let(:role) { create(:role, permissions:) }
@@ -49,7 +49,6 @@ describe 'Subtasks action board', js: true do
let!(:child) { create(:work_package, project:, subject: 'Child WP', parent:, status: open_status) }
before do
- with_enterprise_token :board_view
login_as(user)
end
diff --git a/modules/boards/spec/features/action_boards/version_board_spec.rb b/modules/boards/spec/features/action_boards/version_board_spec.rb
index 0a17958e07e..0f5e85d5a71 100644
--- a/modules/boards/spec/features/action_boards/version_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/version_board_spec.rb
@@ -31,7 +31,7 @@ require_relative './../support//board_index_page'
require_relative './../support/board_page'
# rubocop:disable RSpec:MultipleMemoizedHelpers
-describe 'Version action board', js: true do
+describe 'Version action board', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_projects: [project, second_project],
@@ -88,7 +88,6 @@ describe 'Version action board', js: true do
end
before do
- with_enterprise_token :board_view
project
end
diff --git a/modules/boards/spec/features/board_conflicts_spec.rb b/modules/boards/spec/features/board_conflicts_spec.rb
index ee70805e34f..b280f44c697 100644
--- a/modules/boards/spec/features/board_conflicts_spec.rb
+++ b/modules/boards/spec/features/board_conflicts_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Board remote changes resolution', js: true do
+describe 'Board remote changes resolution', js: true, with_ee: %i[board_view] do
let(:user1) do
create(:user,
member_in_project: project,
@@ -53,7 +53,6 @@ describe 'Board remote changes resolution', js: true do
let!(:work_package2) { create(:work_package, project:, subject: 'Work package B', status: open_status) }
before do
- with_enterprise_token :board_view
project
login_as(user1)
end
diff --git a/modules/boards/spec/features/board_enterprise_spec.rb b/modules/boards/spec/features/board_enterprise_spec.rb
index 54026680f2d..d96dc917b46 100644
--- a/modules/boards/spec/features/board_enterprise_spec.rb
+++ b/modules/boards/spec/features/board_enterprise_spec.rb
@@ -76,9 +76,8 @@ describe 'Boards enterprise spec', js: true do
end
end
- context 'when EE active' do
+ context 'when EE active', with_ee: %i[board_view] do
before do
- with_enterprise_token :board_view
login_as(admin)
board_index.visit!
end
diff --git a/modules/boards/spec/features/board_highlighting_spec.rb b/modules/boards/spec/features/board_highlighting_spec.rb
index abafca9cdd9..07b05da2b29 100644
--- a/modules/boards/spec/features/board_highlighting_spec.rb
+++ b/modules/boards/spec/features/board_highlighting_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Work Package boards spec', js: true do
+describe 'Work Package boards spec', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -67,7 +67,6 @@ describe 'Work Package boards spec', js: true do
let(:color2) { create(:color) }
before do
- with_enterprise_token :board_view
project
login_as(user)
end
@@ -83,26 +82,26 @@ describe 'Work Package boards spec', js: true do
board_page.expect_card 'Open', wp2.subject
# Highlight type inline is always active
- expect(page).to have_selector('.__hl_inline_type_' + type.id.to_s)
- expect(page).to have_selector('.__hl_inline_type_' + type2.id.to_s)
+ expect(page).to have_selector(".__hl_inline_type_#{type.id}")
+ expect(page).to have_selector(".__hl_inline_type_#{type2.id}")
# Highlight whole card by priority
board_page.change_board_highlighting 'inline', 'Priority'
- expect(page).to have_selector('.__hl_background_priority_' + priority.id.to_s)
- expect(page).to have_selector('.__hl_background_priority_' + priority2.id.to_s)
+ expect(page).to have_selector(".__hl_background_priority_#{priority.id}")
+ expect(page).to have_selector(".__hl_background_priority_#{priority2.id}")
# Highlight whole card by type
board_page.change_board_highlighting 'inline', 'Type'
- expect(page).to have_selector('.__hl_background_type_' + type.id.to_s)
- expect(page).to have_selector('.__hl_background_type_' + type2.id.to_s)
+ expect(page).to have_selector(".__hl_background_type_#{type.id}")
+ expect(page).to have_selector(".__hl_background_type_#{type2.id}")
# Disable highlighting
board_page.change_board_highlighting 'none'
- expect(page).not_to have_selector('.__hl_background_type_' + type.id.to_s)
- expect(page).not_to have_selector('.__hl_background_type_' + type2.id.to_s)
+ expect(page).not_to have_selector(".__hl_background_type_#{type.id}")
+ expect(page).not_to have_selector(".__hl_background_type_#{type2.id}")
# Type is still shown highlighted
- expect(page).to have_selector('.__hl_inline_type_' + type.id.to_s)
- expect(page).to have_selector('.__hl_inline_type_' + type2.id.to_s)
+ expect(page).to have_selector(".__hl_inline_type_#{type.id}")
+ expect(page).to have_selector(".__hl_inline_type_#{type2.id}")
end
end
diff --git a/modules/boards/spec/features/board_management_spec.rb b/modules/boards/spec/features/board_management_spec.rb
index b99d3b2b47b..e46ad55b4b4 100644
--- a/modules/boards/spec/features/board_management_spec.rb
+++ b/modules/boards/spec/features/board_management_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Board management spec', js: true do
+describe 'Board management spec', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -47,7 +47,6 @@ describe 'Board management spec', js: true do
let!(:status) { create(:default_status) }
before do
- with_enterprise_token :board_view
project
login_as(user)
end
@@ -147,7 +146,7 @@ describe 'Board management spec', js: true do
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
- expect(subjects).to match_array ['Task 1']
+ expect(subjects).to contain_exactly('Task 1')
# Move item to Second list
board_page.move_card(0, from: 'First', to: 'Second')
@@ -162,7 +161,7 @@ describe 'Board management spec', js: true do
end
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
- expect(subjects).to match_array ['Task 1']
+ expect(subjects).to contain_exactly('Task 1')
# Reference an existing work package
board_page.reference('Second', work_package)
@@ -170,7 +169,7 @@ describe 'Board management spec', js: true do
board_page.expect_card('Second', work_package.subject)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
- expect(subjects).to match_array [work_package.subject, 'Task 1']
+ expect(subjects).to contain_exactly(work_package.subject, 'Task 1')
# Filter for Task
filters.expect_filter_count 0
@@ -261,7 +260,7 @@ describe 'Board management spec', js: true do
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
- expect(subjects).to match_array ['Task 1']
+ expect(subjects).to contain_exactly('Task 1')
board_page.back_to_index
diff --git a/modules/boards/spec/features/board_navigation_spec.rb b/modules/boards/spec/features/board_navigation_spec.rb
index 1b967c8529b..ef6227650e1 100644
--- a/modules/boards/spec/features/board_navigation_spec.rb
+++ b/modules/boards/spec/features/board_navigation_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Work Package boards spec', js: true do
+describe 'Work Package boards spec', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -49,13 +49,8 @@ describe 'Work Package boards spec', js: true do
let(:destroy_modal) { Components::WorkPackages::DestroyModal.new }
before do
- with_enterprise_token :board_view
project
login_as(user)
- end
-
- before do
- with_enterprise_token :board_view
project
login_as(admin)
end
diff --git a/modules/boards/spec/features/board_reference_work_package_spec.rb b/modules/boards/spec/features/board_reference_work_package_spec.rb
index 02e69edd69b..9c7547ff0f7 100644
--- a/modules/boards/spec/features/board_reference_work_package_spec.rb
+++ b/modules/boards/spec/features/board_reference_work_package_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Board reference work package spec', js: true do
+describe 'Board reference work package spec', js: true, with_ee: %i[board_view] do
let(:user) do
create(:user,
member_in_project: project,
@@ -61,7 +61,6 @@ describe 'Board reference work package spec', js: true do
let!(:version) { create(:version, name: 'Foo version', project:) }
before do
- with_enterprise_token :board_view
project
login_as(user)
end
@@ -87,7 +86,7 @@ describe 'Board reference work package spec', js: true do
queries = board_page.board(reload: true).contained_queries
first = queries.find_by(name: 'First')
ids = first.ordered_work_packages.pluck(:work_package_id)
- expect(ids).to match_array [work_package.id]
+ expect(ids).to contain_exactly(work_package.id)
# Reload work package expect version to be applied by filter
work_package.reload
@@ -130,7 +129,7 @@ describe 'Board reference work package spec', js: true do
queries = board_page.board(reload: true).contained_queries
first = queries.find_by(name: 'First')
ids = first.ordered_work_packages.pluck(:work_package_id)
- expect(ids).to match_array [work_package.id]
+ expect(ids).to contain_exactly(work_package.id)
work_package.reload
expect(work_package.project).to eq(child_project)
diff --git a/modules/boards/spec/features/board_update_spec.rb b/modules/boards/spec/features/board_update_spec.rb
index 143f46b6738..091706ed228 100644
--- a/modules/boards/spec/features/board_update_spec.rb
+++ b/modules/boards/spec/features/board_update_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Work Package boards updating spec', js: true do
+describe 'Work Package boards updating spec', js: true, with_ee: %i[board_view] do
let(:admin) { create(:admin) }
let(:project) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
@@ -41,7 +41,6 @@ describe 'Work Package boards updating spec', js: true do
let!(:board_view) { create(:board_grid_with_query, name: 'My board', project:) }
before do
- with_enterprise_token :board_view
project
login_as(admin)
board_index.visit!
diff --git a/modules/boards/spec/features/boards_sorting_spec.rb b/modules/boards/spec/features/boards_sorting_spec.rb
index 6c1ec36f15d..801593e5dbd 100644
--- a/modules/boards/spec/features/boards_sorting_spec.rb
+++ b/modules/boards/spec/features/boards_sorting_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-describe 'Work Package boards sorting spec', js: true do
+describe 'Work Package boards sorting spec', js: true, with_ee: %i[board_view] do
let(:admin) { create(:admin) }
let(:project) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
let(:board_index) { Pages::BoardIndex.new(project) }
@@ -39,7 +39,6 @@ describe 'Work Package boards sorting spec', js: true do
let(:query_menu) { Components::WorkPackages::QueryMenu.new }
before do
- with_enterprise_token :board_view
project
login_as(admin)
board_index.visit!
diff --git a/modules/boards/spec/features/onboarding/boards_onboarding_tour_spec.rb b/modules/boards/spec/features/onboarding/boards_onboarding_tour_spec.rb
index f32d6e04568..78b4ba01634 100644
--- a/modules/boards/spec/features/onboarding/boards_onboarding_tour_spec.rb
+++ b/modules/boards/spec/features/onboarding/boards_onboarding_tour_spec.rb
@@ -83,9 +83,8 @@ describe 'boards onboarding tour', js: true do
end
context 'as a new user' do
- context 'with an EE token' do
+ context 'with an EE token', with_ee: %i[board_view] do
before do
- with_enterprise_token :board_view
login_as user
end
diff --git a/modules/dashboards/spec/features/work_package_graph_spec.rb b/modules/dashboards/spec/features/work_package_graph_spec.rb
index 25a03c567da..72043797a0e 100644
--- a/modules/dashboards/spec/features/work_package_graph_spec.rb
+++ b/modules/dashboards/spec/features/work_package_graph_spec.rb
@@ -30,7 +30,8 @@ require 'spec_helper'
require_relative '../support/pages/dashboard'
-describe 'Arbitrary WorkPackage query graph widget dashboard', js: true, with_mail: false do
+describe 'Arbitrary WorkPackage query graph widget dashboard',
+ js: true, with_ee: %i[grid_widget_wp_graph], with_mail: false do
let!(:type) { create(:type) }
let!(:other_type) { create(:type) }
let!(:priority) { create(:default_priority) }
@@ -85,15 +86,12 @@ describe 'Arbitrary WorkPackage query graph widget dashboard', js: true, with_ma
let(:dashboard_page) do
Pages::Dashboard.new(project)
end
- let(:enterprise_edition) { true }
let(:modal) { Components::WorkPackages::TableConfigurationModal.new }
let(:filters) { Components::WorkPackages::TableConfiguration::Filters.new }
let(:general) { Components::WorkPackages::TableConfiguration::GraphGeneral.new }
before do
- with_enterprise_token(enterprise_edition ? :grid_widget_wp_graph : nil)
-
login_as user
dashboard_page.visit!
@@ -168,9 +166,7 @@ describe 'Arbitrary WorkPackage query graph widget dashboard', js: true, with_ma
end
end
- context 'without an enterprise edition' do
- let(:enterprise_edition) { false }
-
+ context 'without an enterprise edition', with_ee: false do
it 'cannot add the widget and receives an enterprise edition notice' do
dashboard_page.expect_add_widget_enterprise_edition_notice(1, 2, :within)
diff --git a/modules/openid_connect/spec/controllers/providers_controller_spec.rb b/modules/openid_connect/spec/controllers/providers_controller_spec.rb
index 26cd3e12e14..075c5a40573 100644
--- a/modules/openid_connect/spec/controllers/providers_controller_spec.rb
+++ b/modules/openid_connect/spec/controllers/providers_controller_spec.rb
@@ -41,10 +41,9 @@ describe OpenIDConnect::ProvidersController do
before do
login_as user
- without_enterprise_token
end
- context 'without an EE token' do
+ context 'without an EE token', with_ee: false do
it 'renders upsale' do
get :index
expect(response).to have_http_status(:ok)
@@ -52,10 +51,9 @@ describe OpenIDConnect::ProvidersController do
end
end
- context 'with an EE token' do
+ context 'with an EE token', with_ee: %i[openid_providers] do
before do
login_as user
- with_enterprise_token :openid_providers
end
context 'when not admin' do
diff --git a/modules/openid_connect/spec/requests/openid_connect_spec.rb b/modules/openid_connect/spec/requests/openid_connect_spec.rb
index b09c4f7f2dc..33b9223fe9d 100644
--- a/modules/openid_connect/spec/requests/openid_connect_spec.rb
+++ b/modules/openid_connect/spec/requests/openid_connect_spec.rb
@@ -35,7 +35,8 @@ end
describe 'OpenID Connect',
skip_2fa_stage: true, # Prevent redirects to 2FA stage
- type: :rails_request do
+ type: :rails_request,
+ with_ee: %i[openid_providers] do
let(:host) { OmniAuth::OpenIDConnect::Heroku.new('foo', {}).host }
let(:user_info) do
{
@@ -48,8 +49,6 @@ describe 'OpenID Connect',
end
before do
- with_enterprise_token :openid_providers
-
# The redirect will include an authorisation code.
# Since we don't actually get a valid code in the test we will stub the resulting AccessToken.
allow_any_instance_of(OpenIDConnect::Client).to receive(:access_token!) do
@@ -84,7 +83,7 @@ describe 'OpenID Connect',
# it should redirect to the provider's openid connect authentication endpoint
click_on_signin
- expect(response.status).to be 302
+ expect(response).to have_http_status :found
expect(response.location).to match /https:\/\/#{host}.*$/
params = Rack::Utils.parse_nested_query(response.location.gsub(/^.*\?/, ''))
@@ -97,7 +96,7 @@ describe 'OpenID Connect',
# it should redirect back from the provider to the login page
redirect_from_provider
- expect(response.status).to be 302
+ expect(response).to have_http_status :found
expect(response.location).to match /\/\?first_time_user=true$/
# after_login requires the optional third context parameter
@@ -107,27 +106,27 @@ describe 'OpenID Connect',
expect(response.cookies['_open_project_session_access_token']).to eq 'foo bar baz'
end
- user = User.find_by_mail(user_info[:email])
+ user = User.find_by(mail: user_info[:email])
expect(user).not_to be_nil
expect(user.active?).to be true
##
# it should redirect to the provider again upon clicking on sign-in when the user has been activated
- user = User.find_by_mail(user_info[:email])
+ user = User.find_by(mail: user_info[:email])
user.activate
user.save!
click_on_signin
- expect(response.status).to be 302
+ expect(response).to have_http_status :found
expect(response.location).to match /https:\/\/#{host}.*$/
##
# it should then login the user upon the redirect back from the provider
redirect_from_provider
- expect(response.status).to be 302
+ expect(response).to have_http_status :found
expect(response.location).to match /\/my\/page/
end
@@ -181,8 +180,7 @@ describe 'OpenID Connect',
)
end
- it 'will show no option unless EE' do
- without_enterprise_token
+ it 'will show no option unless EE', with_ee: false do
get '/login'
expect(response.body).not_to match /Google/i
expect(response.body).not_to match /Azure/i
@@ -194,7 +192,7 @@ describe 'OpenID Connect',
expect(response.body).to match /Azure/i
expect { click_on_signin('google') }.not_to raise_error
- expect(response.status).to be 302
+ expect(response).to have_http_status :found
end
end
end
diff --git a/modules/team_planner/spec/features/onboarding/team_planner_onboarding_tour_spec.rb b/modules/team_planner/spec/features/onboarding/team_planner_onboarding_tour_spec.rb
index 9b4cf1cd0ee..09078e05efb 100644
--- a/modules/team_planner/spec/features/onboarding/team_planner_onboarding_tour_spec.rb
+++ b/modules/team_planner/spec/features/onboarding/team_planner_onboarding_tour_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require_relative './../../support/onboarding/onboarding_steps'
-describe 'team planner onboarding tour', js: true do
+describe 'team planner onboarding tour', js: true, with_ee: %i[team_planner_view] do
let(:next_button) { find('.enjoyhint_next_btn') }
let(:demo_project) do
@@ -74,7 +74,6 @@ describe 'team planner onboarding tour', js: true do
before do
team_plan
- with_enterprise_token :team_planner_view
login_as user
allow(Setting).to receive(:demo_projects_available).and_return(true)
diff --git a/modules/team_planner/spec/features/query_handling_spec.rb b/modules/team_planner/spec/features/query_handling_spec.rb
index d72ce37f04d..ced63490ce8 100644
--- a/modules/team_planner/spec/features/query_handling_spec.rb
+++ b/modules/team_planner/spec/features/query_handling_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative '../support/pages/team_planner'
require_relative '../../../../spec/features/views/shared_examples'
-describe 'Team planner query handling', js: true do
+describe 'Team planner query handling', js: true, with_ee: %i[team_planner_view] do
shared_let(:type_task) { create(:type_task) }
shared_let(:type_bug) { create(:type_bug) }
shared_let(:project) do
@@ -80,7 +80,6 @@ describe 'Team planner query handling', js: true do
current_user { user }
before do
- with_enterprise_token(:team_planner_view)
login_as user
team_planner.visit!
diff --git a/modules/team_planner/spec/features/team_planner_add_existing_work_packages_spec.rb b/modules/team_planner/spec/features/team_planner_add_existing_work_packages_spec.rb
index 0251fc54b31..c94ade5f454 100644
--- a/modules/team_planner/spec/features/team_planner_add_existing_work_packages_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_add_existing_work_packages_spec.rb
@@ -72,9 +72,8 @@ describe 'Team planner add existing work packages', js: true do
let(:add_existing_pane) { Components::AddExistingPane.new }
let(:filters) { Components::WorkPackages::Filters.new }
- context 'with full permissions' do
+ context 'with full permissions', with_ee: %i[team_planner_view] do
before do
- with_enterprise_token(:team_planner_view)
team_planner.visit!
team_planner.add_assignee user
diff --git a/modules/team_planner/spec/features/team_planner_context_menu_spec.rb b/modules/team_planner/spec/features/team_planner_context_menu_spec.rb
index 64b3c28e75b..7941e2d51ec 100644
--- a/modules/team_planner/spec/features/team_planner_context_menu_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_context_menu_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require_relative 'shared_context'
require 'features/work_packages/table/context_menu/context_menu_shared_examples'
-describe 'Work package table context menu', js: true do
+describe 'Work package table context menu', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
let!(:work_package) do
@@ -26,7 +26,6 @@ describe 'Work package table context menu', js: true do
end
before do
- with_enterprise_token(:team_planner_view)
login_as user
team_planner.visit!
diff --git a/modules/team_planner/spec/features/team_planner_create_spec.rb b/modules/team_planner/spec/features/team_planner_create_spec.rb
index cc8572a9e1b..e5adc5923cd 100644
--- a/modules/team_planner/spec/features/team_planner_create_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_create_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner create new work package', js: true do
+describe 'Team planner create new work package', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
let(:type_task) { create(:type_task) }
@@ -37,7 +37,6 @@ describe 'Team planner create new work package', js: true do
let!(:priority) { create(:default_priority) }
before do
- with_enterprise_token(:team_planner_view)
project.types << type_task
end
diff --git a/modules/team_planner/spec/features/team_planner_dates_spec.rb b/modules/team_planner/spec/features/team_planner_dates_spec.rb
index f6853e1dd8b..c495d614bcd 100644
--- a/modules/team_planner/spec/features/team_planner_dates_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_dates_spec.rb
@@ -29,11 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner working days', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner working days', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
context 'with week days defined' do
diff --git a/modules/team_planner/spec/features/team_planner_error_handling_spec.rb b/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
index d1daca51597..1e0fc331dcf 100644
--- a/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
@@ -50,9 +50,8 @@ describe 'Team planner error handling', js: true do
let(:type) { create(:type, custom_fields: [custom_field]) }
- context 'with full permissions' do
+ context 'with full permissions', with_ee: %i[team_planner_view] do
before do
- with_enterprise_token(:team_planner_view)
project.types << type
project.save!
diff --git a/modules/team_planner/spec/features/team_planner_project_include_spec.rb b/modules/team_planner/spec/features/team_planner_project_include_spec.rb
index 2bc753f0388..a95bf71160f 100644
--- a/modules/team_planner/spec/features/team_planner_project_include_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_project_include_spec.rb
@@ -30,11 +30,7 @@ require 'spec_helper'
require 'features/work_packages/project_include/project_include_shared_examples'
require_relative '../support/pages/team_planner'
-describe 'Team planner project include', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner project include', js: true, with_ee: %i[team_planner_view] do
shared_let(:enabled_modules) { %w[work_package_tracking team_planner_view] }
shared_let(:permissions) do
%w[view_work_packages edit_work_packages add_work_packages
diff --git a/modules/team_planner/spec/features/team_planner_remove_event_spec.rb b/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
index 91bf17465b6..78fa27f7629 100644
--- a/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './shared_context'
require_relative '../support/components/add_existing_pane'
-describe 'Team planner remove event', js: true do
+describe 'Team planner remove event', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
let!(:viewer_role) { create(:existing_role, permissions: [:view_work_packages]) }
@@ -74,7 +74,6 @@ describe 'Team planner remove event', js: true do
end
before do
- with_enterprise_token(:team_planner_view)
team_planner.visit!
team_planner.add_assignee other_user
diff --git a/modules/team_planner/spec/features/team_planner_spec.rb b/modules/team_planner/spec/features/team_planner_spec.rb
index 3c2c64ddbe5..664a14fa2ad 100644
--- a/modules/team_planner/spec/features/team_planner_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_spec.rb
@@ -29,11 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
it 'hides the internally used filters' do
@@ -332,8 +328,7 @@ describe 'Team planner', js: true do
subject: 'A blocked task')
end
- it 'disables editing on readonly tasks' do
- with_enterprise_token(:team_planner_view, :readonly_work_packages)
+ it 'disables editing on readonly tasks', with_ee: %i[team_planner_view readonly_work_packages] do
team_planner.visit!
team_planner.wait_for_loaded
diff --git a/modules/team_planner/spec/features/team_planner_subproject_constraints_spec.rb b/modules/team_planner/spec/features/team_planner_subproject_constraints_spec.rb
index bfc4394a899..84e99f64786 100644
--- a/modules/team_planner/spec/features/team_planner_subproject_constraints_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_subproject_constraints_spec.rb
@@ -29,11 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner constraints for a subproject', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner constraints for a subproject', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
let!(:other_user) do
diff --git a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
index 0a4bdc3b1cc..11bc0455d2b 100644
--- a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
@@ -29,11 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner drag&dop and resizing', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner drag&dop and resizing', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
let!(:other_user) do
diff --git a/modules/team_planner/spec/features/team_planner_view_modes_spec.rb b/modules/team_planner/spec/features/team_planner_view_modes_spec.rb
index b3acb6dfd59..67495da63d2 100644
--- a/modules/team_planner/spec/features/team_planner_view_modes_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_view_modes_spec.rb
@@ -29,11 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner', js: true do
- before do
- with_enterprise_token(:team_planner_view)
- end
-
+describe 'Team planner', js: true, with_ee: %i[team_planner_view] do
include_context 'with team planner full access'
it 'allows switching of view modes', with_settings: { working_days: [1, 2, 3, 4, 5] } do
diff --git a/spec/contracts/queries/create_contract_spec.rb b/spec/contracts/queries/create_contract_spec.rb
index 13c62a63256..1a5f0367ae0 100644
--- a/spec/contracts/queries/create_contract_spec.rb
+++ b/spec/contracts/queries/create_contract_spec.rb
@@ -47,7 +47,7 @@ describe Queries::CreateContract do
it_behaves_like 'contract is valid'
end
- context 'when falsea' do
+ context 'when false' do
let(:include_subprojects) { false }
it_behaves_like 'contract is valid'
diff --git a/spec/controllers/attribute_help_texts_controller_spec.rb b/spec/controllers/attribute_help_texts_controller_spec.rb
index 120debcfdd8..686468bb17a 100644
--- a/spec/controllers/attribute_help_texts_controller_spec.rb
+++ b/spec/controllers/attribute_help_texts_controller_spec.rb
@@ -1,9 +1,8 @@
require 'spec_helper'
-describe AttributeHelpTextsController do
+describe AttributeHelpTextsController, with_ee: %i[attribute_help_texts] do
let(:user) { build_stubbed(:admin) }
let(:model) { build(:work_package_help_text) }
- let(:enterprise_token) { true }
let(:find_expectation) do
allow(AttributeHelpText)
@@ -13,7 +12,6 @@ describe AttributeHelpTextsController do
end
before do
- with_enterprise_token(enterprise_token ? :attribute_help_texts : nil)
login_as user
end
@@ -29,9 +27,7 @@ describe AttributeHelpTextsController do
expect(assigns(:texts_by_type)).to eql('WorkPackage' => [model])
end
- context 'with help texts disallowed by the enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'with help texts disallowed by the enterprise token', with_ee: false do
it 'redirects to upsale' do
expect(response).to redirect_to upsale_attribute_help_texts_path
end
@@ -52,9 +48,7 @@ describe AttributeHelpTextsController do
end
end
- context 'with help texts disallowed by the enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'with help texts disallowed by the enterprise token', with_ee: false do
it 'redirects to upsale' do
expect(response).to redirect_to upsale_attribute_help_texts_path
end
@@ -69,7 +63,7 @@ describe AttributeHelpTextsController do
end
it 'returns 404' do
- expect(response.status).to eq 404
+ expect(response).to have_http_status :not_found
end
end
end
@@ -130,13 +124,11 @@ describe AttributeHelpTextsController do
end
it 'returns 404' do
- expect(response.status).to eq 404
+ expect(response).to have_http_status :not_found
end
end
- context 'with help texts disallowed by the enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'with help texts disallowed by the enterprise token', with_ee: false do
before do
call
end
diff --git a/spec/controllers/custom_actions_controller_spec.rb b/spec/controllers/custom_actions_controller_spec.rb
index 159857b8809..b1967e0b7ba 100644
--- a/spec/controllers/custom_actions_controller_spec.rb
+++ b/spec/controllers/custom_actions_controller_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe CustomActionsController do
+describe CustomActionsController, with_ee: %i[custom_actions] do
let(:admin) { build(:admin) }
let(:non_admin) { build(:user) }
let(:action) { build_stubbed(:custom_action) }
@@ -36,18 +36,9 @@ describe CustomActionsController do
{ custom_action: { name: 'blubs',
actions: { assigned_to: 1 } } }
end
- let(:enterprise_token) { true }
-
- before do
- if enterprise_token
- with_enterprise_token :custom_actions
- end
- end
shared_examples_for 'read requires enterprise token' do
- context 'without an enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'without an enterprise token', with_ee: false do
before do
login_as(admin)
@@ -62,9 +53,7 @@ describe CustomActionsController do
end
shared_examples_for 'write requires enterprise token' do
- context 'without an enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'without an enterprise token', with_ee: false do
before do
login_as(admin)
@@ -121,7 +110,7 @@ describe CustomActionsController do
it 'assigns the custom actions' do
expect(assigns(:custom_actions))
- .to match_array [action]
+ .to contain_exactly(action)
end
end
diff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rb
index 8978a843e05..04b5fd4b467 100644
--- a/spec/controllers/custom_styles_controller_spec.rb
+++ b/spec/controllers/custom_styles_controller_spec.rb
@@ -41,11 +41,7 @@ describe CustomStylesController do
render_views
- context 'when active token exists' do
- before do
- with_enterprise_token(:define_custom_style)
- end
-
+ context 'when active token exists', with_ee: %i[define_custom_style] do
it 'renders show' do
expect(subject).to be_successful
expect(response).to render_template 'show'
@@ -74,7 +70,7 @@ describe CustomStylesController do
end
end
- describe "#create" do
+ describe "#create", with_ee: %i[define_custom_style] do
let(:custom_style) { CustomStyle.new }
let(:params) do
{
@@ -83,8 +79,6 @@ describe CustomStylesController do
end
before do
- with_enterprise_token(:define_custom_style)
-
expect(CustomStyle).to receive(:create).and_return(custom_style)
expect(custom_style).to receive(:valid?).and_return(valid)
@@ -109,7 +103,7 @@ describe CustomStylesController do
end
end
- describe "#update" do
+ describe "#update", with_ee: %i[define_custom_style] do
let(:custom_style) { build(:custom_style_with_logo) }
let(:params) do
{
@@ -119,8 +113,6 @@ describe CustomStylesController do
context 'with an existing CustomStyle' do
before do
- with_enterprise_token(:define_custom_style)
-
expect(CustomStyle).to receive(:current).and_return(custom_style)
expect(custom_style).to receive(:update).and_return(valid)
@@ -147,8 +139,6 @@ describe CustomStylesController do
context 'without an existing CustomStyle' do
before do
- with_enterprise_token(:define_custom_style)
-
expect(CustomStyle).to receive(:create!).and_return(custom_style)
expect(custom_style).to receive(:update).and_return(valid)
@@ -187,7 +177,7 @@ describe CustomStylesController do
let(:custom_style) { build(:custom_style_with_logo) }
it 'will send a file' do
- expect(response.status).to eq(200)
+ expect(response).to have_http_status(:ok)
end
end
@@ -196,7 +186,7 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
@@ -205,18 +195,14 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
end
- describe "#logo_delete" do
+ describe "#logo_delete", with_ee: %i[define_custom_style] do
let(:custom_style) { create(:custom_style_with_logo) }
- before do
- with_enterprise_token(:define_custom_style)
- end
-
context 'if it exists' do
before do
expect(CustomStyle).to receive(:current).and_return(custom_style)
@@ -236,7 +222,7 @@ describe CustomStylesController do
end
it 'renders 404' do
- expect(response.status).to eq 404
+ expect(response).to have_http_status :not_found
end
end
end
@@ -254,7 +240,7 @@ describe CustomStylesController do
let(:custom_style) { build(:custom_style_with_favicon) }
it 'will send a file' do
- expect(response.status).to eq(200)
+ expect(response).to have_http_status(:ok)
end
end
@@ -263,7 +249,7 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
@@ -272,18 +258,14 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
end
- describe "#favicon_delete" do
+ describe "#favicon_delete", with_ee: %i[define_custom_style] do
let(:custom_style) { create(:custom_style_with_favicon) }
- before do
- with_enterprise_token(:define_custom_style)
- end
-
context 'if it exists' do
before do
expect(CustomStyle).to receive(:current).and_return(custom_style)
@@ -303,7 +285,7 @@ describe CustomStylesController do
end
it 'renders 404' do
- expect(response.status).to eq 404
+ expect(response).to have_http_status :not_found
end
end
end
@@ -321,7 +303,7 @@ describe CustomStylesController do
let(:custom_style) { build(:custom_style_with_touch_icon) }
it 'will send a file' do
- expect(response.status).to eq(200)
+ expect(response).to have_http_status(:ok)
end
end
@@ -330,7 +312,7 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
@@ -339,18 +321,14 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
end
- describe "#touch_icon_delete" do
+ describe "#touch_icon_delete", with_ee: %i[define_custom_style] do
let(:custom_style) { create(:custom_style_with_touch_icon) }
- before do
- with_enterprise_token(:define_custom_style)
- end
-
context 'if it exists' do
before do
expect(CustomStyle).to receive(:current).and_return(custom_style)
@@ -370,12 +348,12 @@ describe CustomStylesController do
end
it 'renders 404' do
- expect(response.status).to eq 404
+ expect(response).to have_http_status :not_found
end
end
end
- describe "#update_colors" do
+ describe "#update_colors", with_ee: %i[define_custom_style] do
let(:params) do
{
design_colors: [{ "primary-color" => "#990000" }]
@@ -383,8 +361,6 @@ describe CustomStylesController do
end
before do
- with_enterprise_token(:define_custom_style)
-
post :update_colors, params:
end
@@ -421,7 +397,7 @@ describe CustomStylesController do
end
it 'requires admin' do
- expect(response.status).to eq 403
+ expect(response).to have_http_status :forbidden
end
end
end
@@ -442,7 +418,7 @@ describe CustomStylesController do
let(:custom_style) { build(:custom_style_with_logo) }
it 'will send a file' do
- expect(response.status).to eq(200)
+ expect(response).to have_http_status(:ok)
end
end
@@ -451,7 +427,7 @@ describe CustomStylesController do
it 'renders with error' do
expect(controller).not_to receive(:send_file)
- expect(response.status).to eq(404)
+ expect(response).to have_http_status(:not_found)
end
end
end
diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb
index 7c58650868b..b80e8556499 100644
--- a/spec/features/admin/attribute_help_texts_spec.rb
+++ b/spec/features/admin/attribute_help_texts_spec.rb
@@ -37,10 +37,8 @@ describe 'Attribute help texts', js: true do
let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }
let(:enterprise_token) { true }
- describe 'Work package help texts' do
+ describe 'Work package help texts', with_ee: %i[attribute_help_texts] do
before do
- with_enterprise_token(enterprise_token ? :attribute_help_texts : nil)
-
login_as(admin)
visit attribute_help_texts_path
end
@@ -151,9 +149,7 @@ describe 'Attribute help texts', js: true do
end
end
- context 'with help texts disallowed by the enterprise token' do
- let(:enterprise_token) { false }
-
+ context 'with help texts disallowed by the enterprise token', with_ee: false do
it 'hides CRUD to attribute help texts' do
expect(page).to have_current_path /upsale/
expect(page).to have_text I18n.t('attribute_help_texts.enterprise.description')
diff --git a/spec/features/placeholder_users/index_spec.rb b/spec/features/placeholder_users/index_spec.rb
index 27f9d254152..de67fe2c79d 100644
--- a/spec/features/placeholder_users/index_spec.rb
+++ b/spec/features/placeholder_users/index_spec.rb
@@ -28,11 +28,7 @@
require 'spec_helper'
-describe 'index placeholder users', js: true do
- before do
- with_enterprise_token(:placeholder_users)
- end
-
+describe 'index placeholder users', js: true, with_ee: %i[placeholder_users] do
let!(:current_user) { create(:admin) }
let!(:anonymous) { create(:anonymous) }
let!(:placeholder_user_1) do
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index a7ae3ed9faf..f4fbee5b55b 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -67,10 +67,6 @@ describe 'Projects index page',
projects_page.open_filters
end
- def allow_enterprise_edition
- with_enterprise_token(:custom_fields_in_projects_list)
- end
-
def remove_filter(name)
page.find("li[filter-name='#{name}'] .filter_rem").click
end
@@ -101,7 +97,7 @@ describe 'Projects index page',
end
end
- describe 'for project members' do
+ describe 'for project members', with_ee: %i[custom_fields_in_projects_list] do
shared_let(:user) do
create(:user,
member_in_project: development_project,
@@ -111,10 +107,6 @@ describe 'Projects index page',
lastname: 'Turing')
end
- before do
- allow_enterprise_edition
- end
-
it 'only public project or those the user is member of shall be visible' do
Role.non_member
login_as(user)
@@ -196,11 +188,7 @@ describe 'Projects index page',
end
end
- describe 'with valid Enterprise token' do
- before do
- allow_enterprise_edition
- end
-
+ describe 'with valid Enterprise token', with_ee: %i[custom_fields_in_projects_list] do
it 'CF columns and filters are not visible by default' do
load_and_open_filters admin
@@ -510,7 +498,7 @@ describe 'Projects index page',
end
end
- describe 'other filter types' do
+ describe 'other filter types', with_ee: %i[custom_fields_in_projects_list] do
include ActiveSupport::Testing::TimeHelpers
shared_let(:list_custom_field) { create(:list_project_custom_field) }
@@ -563,7 +551,6 @@ describe 'Projects index page',
end
before do
- allow_enterprise_edition
project_created_on_today
load_and_open_filters admin
SeleniumHubWaiter.wait
@@ -875,7 +862,7 @@ describe 'Projects index page',
end
end
- describe 'order' do
+ describe 'order', with_ee: %i[custom_fields_in_projects_list] do
shared_let(:integer_custom_field) { create(:int_project_custom_field) }
# order is important here as the implementation uses lft
# first but then reorders in ruby
@@ -896,7 +883,6 @@ describe 'Projects index page',
end
before do
- allow_enterprise_edition
login_as(admin)
visit projects_path
@@ -981,7 +967,7 @@ describe 'Projects index page',
end
end
- context 'with a multi-value custom field' do
+ context 'with a multi-value custom field', with_ee: %i[custom_fields_in_projects_list] do
let!(:list_custom_field) { create(:list_project_custom_field, multi_value: true) }
before do
@@ -990,7 +976,6 @@ describe 'Projects index page',
project.save!
- allow_enterprise_edition
allow(Setting)
.to receive(:enabled_projects_columns)
.and_return [list_custom_field.column_name]
diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb
index 83b3bf76129..0f03f0505c6 100644
--- a/spec/features/types/form_configuration_query_spec.rb
+++ b/spec/features/types/form_configuration_query_spec.rb
@@ -84,9 +84,8 @@ describe 'form query configuration', js: true do
let(:filters) { Components::WorkPackages::TableConfiguration::Filters.new }
let(:columns) { Components::WorkPackages::Columns.new }
- describe "with EE token" do
+ describe "with EE token", with_ee: %i[edit_attribute_groups] do
before do
- with_enterprise_token(:edit_attribute_groups)
login_as(admin)
visit edit_type_tab_path(id: type_bug.id, tab: "form_configuration")
end
diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb
index 3ec0eba32d4..02c059f2834 100644
--- a/spec/features/types/form_configuration_spec.rb
+++ b/spec/features/types/form_configuration_spec.rb
@@ -45,11 +45,7 @@ describe 'form configuration', js: true do
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
let(:form) { Components::Admin::TypeConfigurationForm.new }
- describe "with EE token" do
- before do
- with_enterprise_token(:edit_attribute_groups)
- end
-
+ describe "with EE token", with_ee: %i[edit_attribute_groups] do
describe 'default configuration' do
let(:dialog) { Components::ConfirmationDialog.new }
@@ -376,11 +372,10 @@ describe 'form configuration', js: true do
end
end
- describe "without EE token" do
+ describe "without EE token", with_ee: false do
let(:dialog) { Components::ConfirmationDialog.new }
it "must disable adding and renaming groups" do
- with_enterprise_token(nil)
login_as(admin)
visit edit_type_tab_path(id: type.id, tab: "form_configuration")
diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb
index 9612ae0e964..4413537a80e 100644
--- a/spec/features/types/reset_form_configuration_spec.rb
+++ b/spec/features/types/reset_form_configuration_spec.rb
@@ -36,14 +36,13 @@ describe 'Reset form configuration', js: true do
let(:form) { Components::Admin::TypeConfigurationForm.new }
let(:dialog) { Components::ConfirmationDialog.new }
- describe "with EE token and CFs" do
+ describe "with EE token and CFs", with_ee: %i[edit_attribute_groups] do
let(:custom_fields) { [custom_field] }
let(:custom_field) { create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') }
let(:cf_identifier) { custom_field.attribute_name }
let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }
before do
- with_enterprise_token(:edit_attribute_groups)
project
custom_field
diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb
index 03ae1ed0be7..c6f95e6eff0 100644
--- a/spec/features/work_packages/bulk/update_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb
@@ -142,7 +142,7 @@ describe 'Bulk update work packages through Rails view', js: true do
context 'when editing custom field of work packages with a readonly status (regression#44673)' do
let(:work_package2_status) { create(:status, :readonly) }
- context 'with enterprise', with_ee: [:readonly_work_packages] do
+ context 'with enterprise', with_ee: %i[readonly_work_packages] do
it 'does not update the work packages' do
expect(work_package.send(custom_field.attribute_getter)).to be_nil
expect(work_package2.send(custom_field.attribute_getter)).to be_nil
diff --git a/spec/features/work_packages/custom_actions/custom_actions_me_value_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_me_value_spec.rb
index c71e0609b28..de57ceb5bed 100644
--- a/spec/features/work_packages/custom_actions/custom_actions_me_value_spec.rb
+++ b/spec/features/work_packages/custom_actions/custom_actions_me_value_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe 'Custom actions me value', js: true do
+describe 'Custom actions me value', js: true, with_ee: %i[custom_actions] do
shared_let(:admin) { create(:admin) }
let(:permissions) { %i(view_work_packages edit_work_packages) }
@@ -54,7 +54,6 @@ describe 'Custom actions me value', js: true do
let(:index_ca_page) { Pages::Admin::CustomActions::Index.new }
before do
- with_enterprise_token(:custom_actions)
login_as(admin)
end
diff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
index 822b7a1b829..1c8425757a0 100644
--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb
+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe 'Custom actions', js: true do
+describe 'Custom actions', js: true, with_ee: %i[custom_actions] do
shared_let(:admin) { create(:admin) }
let(:permissions) { %i(view_work_packages edit_work_packages move_work_packages work_package_assigned) }
@@ -140,7 +140,6 @@ describe 'Custom actions', js: true do
let(:index_ca_page) { Pages::Admin::CustomActions::Index.new }
before do
- with_enterprise_token(:custom_actions)
login_as(admin)
end
diff --git a/spec/features/work_packages/table/relations_spec.rb b/spec/features/work_packages/table/relations_spec.rb
index a1aefa5fda6..9969a47cfe3 100644
--- a/spec/features/work_packages/table/relations_spec.rb
+++ b/spec/features/work_packages/table/relations_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Work Package table relations', js: true do
+describe 'Work Package table relations', js: true, with_ee: %i[work_package_query_relation_columns] do
let(:user) { create(:admin) }
let(:type) { create(:type) }
@@ -39,15 +39,8 @@ describe 'Work Package table relations', js: true do
let(:type_column_id) { "relationsToType#{type.id}" }
let(:type_column_follows) { 'relationsOfTypeFollows' }
- let(:relation_columns_allowed) { true }
before do
- # There does not seem to appear a way to generate a valid token
- # for testing purposes
- if relation_columns_allowed
- with_enterprise_token :work_package_query_relation_columns
- end
-
login_as(user)
end
@@ -106,9 +99,7 @@ describe 'Work Package table relations', js: true do
end
end
- describe 'with relation columns disallowed by the enterprise token' do
- let(:relation_columns_allowed) { false }
-
+ describe 'with relation columns disallowed by the enterprise token', with_ee: false do
it 'has no relation columns available for selection' do
# Now visiting the query for category
wp_table.visit_query(query)
diff --git a/spec/helpers/custom_styles_helper_spec.rb b/spec/helpers/custom_styles_helper_spec.rb
index c4940cf246c..3595df995dc 100644
--- a/spec/helpers/custom_styles_helper_spec.rb
+++ b/spec/helpers/custom_styles_helper_spec.rb
@@ -49,11 +49,7 @@ describe CustomStylesHelper do
context 'CustomStyle present' do
let(:current_theme) { build_stubbed(:custom_style) }
- context 'without EE' do
- before do
- without_enterprise_token
- end
-
+ context 'without EE', with_ee: false do
context 'no BIM edition' do
it 'is falsey' do
expect(subject).to be_falsey
@@ -69,11 +65,7 @@ describe CustomStylesHelper do
end
end
- context 'with EE' do
- before do
- with_enterprise_token(:define_custom_style)
- end
-
+ context 'with EE', with_ee: %i[define_custom_style] do
context 'no BIM edition' do
it 'is truthy' do
expect(subject).to be_truthy
@@ -106,21 +98,13 @@ describe CustomStylesHelper do
allow(current_theme).to receive(:touch_icon).and_return(true)
end
- context 'without EE' do
- before do
- without_enterprise_token
- end
-
+ context 'without EE', with_ee: false do
it 'is falsey' do
expect(subject).to be_falsey
end
end
- context 'with EE' do
- before do
- with_enterprise_token(:define_custom_style)
- end
-
+ context 'with EE', with_ee: %i[define_custom_style] do
it 'is truthy' do
expect(subject).to be_truthy
end
diff --git a/spec/lib/api/v3/queries/query_representer_parsing_spec.rb b/spec/lib/api/v3/queries/query_representer_parsing_spec.rb
index ae50f80200d..0ee25dc5c9e 100644
--- a/spec/lib/api/v3/queries/query_representer_parsing_spec.rb
+++ b/spec/lib/api/v3/queries/query_representer_parsing_spec.rb
@@ -86,7 +86,7 @@ describe API::V3::Queries::QueryRepresenter, 'parsing' do
end
end
- describe 'highlighted_attributes', with_ee: [:conditional_highlighting] do
+ describe 'highlighted_attributes', with_ee: %i[conditional_highlighting] do
let(:request_body) do
{
'_links' => {
diff --git a/spec/models/queries/notifications/filters/reason_filter_spec.rb b/spec/models/queries/notifications/filters/reason_filter_spec.rb
index 7db11d0f188..55e12a26b1e 100644
--- a/spec/models/queries/notifications/filters/reason_filter_spec.rb
+++ b/spec/models/queries/notifications/filters/reason_filter_spec.rb
@@ -39,7 +39,7 @@ describe Queries::Notifications::Filters::ReasonFilter do
it_behaves_like 'non ar filter'
describe '#allowed_values' do
- context 'with enterprise', with_ee: [:date_alerts] do
+ context 'with enterprise', with_ee: %i[date_alerts] do
it 'contains all the REASONS' do
expect(instance.allowed_values).to eq(described_class::REASONS.keys.map { |r| [r, r] })
end
diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb
index 880e2187c99..d3391c59984 100644
--- a/spec/models/setting_spec.rb
+++ b/spec/models/setting_spec.rb
@@ -254,7 +254,7 @@ describe Setting do
end
it "returns unknown if the settings table isn't available yet" do
- allow(Setting)
+ allow(described_class)
.to receive(:settings_table_exists_yet?)
.and_return(false)
expect(described_class.installation_uuid).to eq("unknown")
@@ -268,7 +268,7 @@ describe Setting do
it "returns the existing value if any" do
# can't use with_settings since described_class.installation_uuid has a custom implementation
- allow(Setting).to receive(:installation_uuid).and_return "abcd1234"
+ allow(described_class).to receive(:installation_uuid).and_return "abcd1234"
expect(described_class.installation_uuid).to eq("abcd1234")
end
@@ -297,7 +297,7 @@ describe Setting do
# Check that when reading certain setting values that they get overwritten if needed.
describe "filter saved settings" do
- describe "with EE token", with_ee: [:conditional_highlighting] do
+ describe "with EE token", with_ee: %i[conditional_highlighting] do
it "returns the value for 'work_package_list_default_highlighting_mode' without changing it" do
expect(described_class.work_package_list_default_highlighting_mode).to eq("inline")
end
@@ -382,12 +382,12 @@ describe Setting do
context 'when cache is empty' do
it 'requests the settings once from database' do
- expect(Setting).to receive(:pluck).with(:name, :value)
+ allow(described_class).to receive(:pluck).with(:name, :value)
.once
.and_call_original
- expect(Rails.cache).to receive(:fetch).once.and_call_original
- expect(RequestStore).to receive(:fetch).exactly(3).times.and_call_original
+ allow(Rails.cache).to receive(:fetch).once.and_call_original
+ allow(RequestStore).to receive(:fetch).exactly(3).times.and_call_original
# Settings are empty by default
expect(RequestStore.read(:cached_settings)).to be_nil
@@ -398,6 +398,10 @@ describe Setting do
expect(described_class.app_title).to eq 'OpenProject'
expect(value).to eq(described_class.app_title)
+ expect(described_class).to have_received(:pluck).with(:name, :value).once
+ expect(Rails.cache).to have_received(:fetch).once
+ expect(RequestStore).to have_received(:fetch).exactly(3)
+
# Settings are empty by default
expect(RequestStore.read(:cached_settings)).to eq({})
expect(Rails.cache.read(cache_key)).to eq({})
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index f3f7ef25120..cbec0c9095c 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -74,7 +74,7 @@ describe Status do
end
end
- context 'when EE no longer enabled', with_ee: %i[] do
+ context 'when EE no longer enabled', with_ee: false do
it 'is still marked read only' do
expect(status.is_readonly).to be_falsey
expect(status).not_to be_is_readonly
@@ -90,7 +90,7 @@ describe Status do
it 'updates when the updated_at field changes' do
old_cache_key = stubbed_status.cache_key
- stubbed_status.updated_at = Time.now
+ stubbed_status.updated_at = Time.zone.now
expect(stubbed_status.cache_key)
.not_to eql old_cache_key
diff --git a/spec/requests/api/v3/notifications/index_resource_spec.rb b/spec/requests/api/v3/notifications/index_resource_spec.rb
index 8cad452bb4f..5f6f2ebee45 100644
--- a/spec/requests/api/v3/notifications/index_resource_spec.rb
+++ b/spec/requests/api/v3/notifications/index_resource_spec.rb
@@ -160,7 +160,7 @@ describe API::V3::Notifications::NotificationsAPI,
end
end
- context 'with a reason filter', with_ee: [:date_alerts] do
+ context 'with a reason filter', with_ee: %i[date_alerts] do
shared_let(:assigned_notification) do
create(:notification,
reason: :assigned,
diff --git a/spec/requests/openid_google_provider_callback_spec.rb b/spec/requests/openid_google_provider_callback_spec.rb
index 0f161914a77..50fb32e395a 100644
--- a/spec/requests/openid_google_provider_callback_spec.rb
+++ b/spec/requests/openid_google_provider_callback_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require 'rack/test'
-describe 'OpenID Google provider callback' do
+describe 'OpenID Google provider callback', with_ee: %i[openid_providers] do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -57,8 +57,6 @@ describe 'OpenID Google provider callback' do
.with(provider: "google")
.and_return false
- with_enterprise_token :openid_providers
-
stub_request(:post, "https://accounts.google.com/o/oauth2/token").to_return(
status: 200,
body: {
diff --git a/spec/services/projects/copy_service_integration_spec.rb b/spec/services/projects/copy_service_integration_spec.rb
index dfd74e53846..a32e809a34d 100644
--- a/spec/services/projects/copy_service_integration_spec.rb
+++ b/spec/services/projects/copy_service_integration_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Projects::CopyService, 'integration', type: :model do
+describe Projects::CopyService, 'integration', type: :model, with_ee: %i[readonly_work_packages] do
shared_let(:status_locked) { create(:status, is_readonly: true) }
shared_let(:source) { create(:project, enabled_module_names: %w[wiki work_package_tracking]) }
shared_let(:source_wp) { create(:work_package, project: source, subject: 'source wp') }
@@ -65,8 +65,6 @@ describe Projects::CopyService, 'integration', type: :model do
shared_let(:new_project_role) { create(:role, permissions: %i[]) }
before do
- with_enterprise_token(:readonly_work_packages)
-
allow(Setting)
.to receive(:new_project_user_role_id)
.and_return(new_project_role.id.to_s)
@@ -145,7 +143,7 @@ describe Projects::CopyService, 'integration', type: :model do
expect(member.principal)
.to eql(current_user)
expect(member.roles)
- .to match_array [role, new_project_role]
+ .to contain_exactly(role, new_project_role)
end
it 'will copy the work package with category' do
@@ -562,7 +560,7 @@ describe Projects::CopyService, 'integration', type: :model do
it 'does copy active watchers but does not add the copying user as a watcher' do
expect(subject).to be_success
expect(project_copy.work_packages[0].watcher_users)
- .to match_array([watcher])
+ .to contain_exactly(watcher)
end
end
diff --git a/spec/support/enterprise_token_helper.rb b/spec/support/enterprise_token_helper.rb
deleted file mode 100644
index a47c7e1cf0f..00000000000
--- a/spec/support/enterprise_token_helper.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2023 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module AuthenticationHelpers
- def with_enterprise_token(*features)
- allow(EnterpriseToken)
- .to receive(:allows_to?)
- .and_return(false)
-
- if features.compact.length > 0
- features.each do |feature|
- allow(EnterpriseToken)
- .to receive(:allows_to?)
- .with(feature)
- .and_return(true)
- end
-
- allow(EnterpriseToken).to receive(:show_banners?).and_return(false)
- else
- allow(EnterpriseToken).to receive(:show_banners?).and_return(true)
- end
-
- allow(OpenProject::Configuration).to receive(:ee_manager_visible?).and_return(false)
- end
-
- def without_enterprise_token
- # Calling without params means no EE features are allowed.
- with_enterprise_token
- end
-end
-
-RSpec.configure do |config|
- config.include AuthenticationHelpers
-end