diff --git a/config/configuration.yml.example b/config/configuration.yml.example index 70af05135c..bb71520cd8 100644 --- a/config/configuration.yml.example +++ b/config/configuration.yml.example @@ -162,14 +162,14 @@ # - 'types' # - 'admin/roles' # -# Enable file storages module: +# Beta features # -# The file storages module is currently under development and can -# be enabled for beta usage by setting a feature flag: +# Some features are hidden behind a feature flag during development. +# To activate one or more features set the correspondig flag inside the section. # +# Example: # production: -# feature_storages_module_active: true -# +# feature_your_module_active: true # default configuration options for all environments default: diff --git a/config/constants/settings/definitions.rb b/config/constants/settings/definitions.rb index 2308139fd3..5494ad2667 100644 --- a/config/constants/settings/definitions.rb +++ b/config/constants/settings/definitions.rb @@ -401,9 +401,13 @@ Settings::Definition.define do default: 'enterprise-on-premises---euro---1-year', writable: false - add :feature_storages_module_active, - default: Rails.env.development?, - format: :boolean + # feature flags + # To add a feature flag register a new definition for a configuration variable + # + # Example: + # add :feature_your_module_active, + # default: Rails.env.development?, + # format: :boolean add :feeds_enabled, default: true diff --git a/lib/open_project/feature_decisions.rb b/lib/open_project/feature_decisions.rb index 4b40cb3b39..d942e3d279 100644 --- a/lib/open_project/feature_decisions.rb +++ b/lib/open_project/feature_decisions.rb @@ -35,15 +35,11 @@ module OpenProject # # For example: # - # def self.storages_module_active? + # def self.your_module_active? # release_date = Date.new(2022,01,01) - # Setting.feature_storages_module_active || Date.today > release_date + # Setting.feature_your_module_active || Date.today > release_date # end - def self.storages_module_active? - Setting.feature_storages_module_active - end - def self.work_packages_duration_field_active? Setting.work_packages_duration_field_active end diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb index 5970ae9000..72ed7fdff8 100644 --- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb +++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb @@ -85,12 +85,6 @@ class Storages::Admin::OAuthClientsController < ApplicationController private - def ensure_storages_module_active - return if OpenProject::FeatureDecisions.storages_module_active? - - raise ActionController::RoutingError, 'Not Found' - end - # Called by create and update above in order to check if the # update parameters are correctly set. def permitted_oauth_client_params diff --git a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb index d7e6346886..99d0478ad5 100644 --- a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb +++ b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb @@ -39,10 +39,6 @@ class Storages::Admin::ProjectsStoragesController < Projects::SettingsController # This defines @object as the model instance. model_object Storages::ProjectStorage - # Will return a 404 if the storages module has not been made available through - # a feature flag. - before_action :ensure_storages_module_active - before_action :find_model_object, only: %i[destroy] # Fill @object with ProjectStorage # No need to before_action :find_project_by_project_id as SettingsController already checks # No need to check for before_action :authorize, as the SettingsController already checks this. @@ -118,12 +114,6 @@ class Storages::Admin::ProjectsStoragesController < Projects::SettingsController private - def ensure_storages_module_active - return if OpenProject::FeatureDecisions.storages_module_active? - - raise ActionController::RoutingError, 'Not Found' - end - # Define the list of permitted parameters for creating/updating a ProjectStorage. # Called by create and update actions above. def permitted_create_params diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb index 7b81dfceb1..3c45b26c33 100644 --- a/modules/storages/app/controllers/storages/admin/storages_controller.rb +++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb @@ -34,10 +34,6 @@ class Storages::Admin::StoragesController < ApplicationController # specify which model #find_model_object should look up model_object Storages::Storage - # Will return a 404 if the storages module has not been made available through - # a feature flag. - before_action :ensure_storages_module_active - # Before executing any action below: Make sure the current user is an admin # and set the @ variable to the object referenced in the URL. before_action :require_admin @@ -175,12 +171,6 @@ class Storages::Admin::StoragesController < ApplicationController service_result.dependent_results&.first&.result end - def ensure_storages_module_active - return if OpenProject::FeatureDecisions.storages_module_active? - - raise ActionController::RoutingError, 'Not Found' - end - # Called by create and update above in order to check if the # update parameters are correctly set. def permitted_storage_params diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/concerns/validate_storages_module_available.rb b/modules/storages/app/models/queries/storages/work_packages/filter/concerns/validate_storages_module_available.rb deleted file mode 100644 index eb2250f1b1..0000000000 --- a/modules/storages/app/models/queries/storages/work_packages/filter/concerns/validate_storages_module_available.rb +++ /dev/null @@ -1,41 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2022 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 Queries::Storages::WorkPackages::Filter::Concerns::ValidateStoragesModuleAvailable - extend ActiveSupport::Concern - - included do - validate :storages_module_available - - def storages_module_available - return if OpenProject::FeatureDecisions.storages_module_active? - - errors.add :base, I18n.t('activerecord.errors.messages.filter_does_not_exist') - end - end -end diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb index 1f708388c3..d1a3c18213 100644 --- a/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb +++ b/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb @@ -29,7 +29,6 @@ module Queries::Storages::WorkPackages::Filter class FileLinkOriginIdFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter include StoragesFilterMixin - include Concerns::ValidateStoragesModuleAvailable def filter_model ::Storages::FileLink diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb index 3165ba8f82..897c937924 100644 --- a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb +++ b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb @@ -29,7 +29,6 @@ module Queries::Storages::WorkPackages::Filter class LinkableToStorageIdFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter include StoragesFilterMixin - include Concerns::ValidateStoragesModuleAvailable def filter_model ::Storages::Storage diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb index 98e14287c5..bcf78a4b09 100644 --- a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb +++ b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb @@ -29,7 +29,6 @@ module Queries::Storages::WorkPackages::Filter class LinkableToStorageUrlFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter include StoragesFilterMixin - include Concerns::ValidateStoragesModuleAvailable def filter_model ::Storages::Storage diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/storage_id_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/storage_id_filter.rb index 4bc8b34f13..f0733a41b7 100644 --- a/modules/storages/app/models/queries/storages/work_packages/filter/storage_id_filter.rb +++ b/modules/storages/app/models/queries/storages/work_packages/filter/storage_id_filter.rb @@ -29,7 +29,6 @@ module Queries::Storages::WorkPackages::Filter class StorageIdFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter include StoragesFilterMixin - include Concerns::ValidateStoragesModuleAvailable def filter_model ::Storages::FileLink diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/storage_url_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/storage_url_filter.rb index c0ec908289..12b2c46419 100644 --- a/modules/storages/app/models/queries/storages/work_packages/filter/storage_url_filter.rb +++ b/modules/storages/app/models/queries/storages/work_packages/filter/storage_url_filter.rb @@ -29,7 +29,6 @@ module Queries::Storages::WorkPackages::Filter class StorageUrlFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter include StoragesFilterMixin - include Concerns::ValidateStoragesModuleAvailable def filter_model ::Storages::Storage diff --git a/modules/storages/lib/api/v3/file_links/file_links_api.rb b/modules/storages/lib/api/v3/file_links/file_links_api.rb index 0d149f96f6..d0a96479ac 100644 --- a/modules/storages/lib/api/v3/file_links/file_links_api.rb +++ b/modules/storages/lib/api/v3/file_links/file_links_api.rb @@ -37,10 +37,6 @@ module API # module available from within the endpoint context. helpers API::V3::Utilities::StoragesHelpers - before do - reply_with_not_found_if_module_inactive - end - # The `:resources` keyword defines the API namespace -> /api/v3/file_links/... resources :file_links do # `route_param` extends the route by a route parameter of the endpoint. diff --git a/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb b/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb index 09e490de2a..066b79ca75 100644 --- a/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb +++ b/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb @@ -38,10 +38,6 @@ module API # module available from within the endpoint context. helpers API::V3::Utilities::StoragesHelpers - before do - reply_with_not_found_if_module_inactive - end - # The `:resources` keyword defines the API namespace -> /api/v3/work_packages/:id/file_links/... resources :file_links do # Get the list of FileLinks related to a work package, with updated information from Nextcloud. diff --git a/modules/storages/lib/api/v3/storages/storages_api.rb b/modules/storages/lib/api/v3/storages/storages_api.rb index 0f39992111..42d0268c64 100644 --- a/modules/storages/lib/api/v3/storages/storages_api.rb +++ b/modules/storages/lib/api/v3/storages/storages_api.rb @@ -39,10 +39,6 @@ module API # module available from within the endpoint context. helpers API::V3::Utilities::StoragesHelpers - before do - reply_with_not_found_if_module_inactive - end - # The `:resources` keyword defines the API namespace -> /api/v3/storages/... resources :storages do # `route_param` extends the route by a route parameter of the endpoint. diff --git a/modules/storages/lib/api/v3/utilities/storages_helpers.rb b/modules/storages/lib/api/v3/utilities/storages_helpers.rb index d8b85c6927..4e73b5cb33 100644 --- a/modules/storages/lib/api/v3/utilities/storages_helpers.rb +++ b/modules/storages/lib/api/v3/utilities/storages_helpers.rb @@ -28,10 +28,6 @@ module API::V3::Utilities module StoragesHelpers - def reply_with_not_found_if_module_inactive - raise ::API::Errors::NotFound unless OpenProject::FeatureDecisions.storages_module_active? - end - def visible_storages_scope ::Storages::Storage.visible(current_user) end diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb index 1cf04e0ca8..1107c78ddb 100644 --- a/modules/storages/lib/open_project/storages/engine.rb +++ b/modules/storages/lib/open_project/storages/engine.rb @@ -51,8 +51,7 @@ module OpenProject::Storages # Defines permission constraints used in the module (controller, etc.) # Permissions documentation: https://www.openproject.org/docs/development/concepts/permissions/#definition-of-permissions project_module :storages, - dependencies: :work_package_tracking, - if: ->(*) { OpenProject::FeatureDecisions.storages_module_active? } do + dependencies: :work_package_tracking do permission :view_file_links, {}, dependencies: %i[view_work_packages], @@ -72,14 +71,13 @@ module OpenProject::Storages menu :admin_menu, :storages_admin_settings, { controller: '/storages/admin/storages', action: :index }, - if: Proc.new { User.current.admin? && OpenProject::FeatureDecisions.storages_module_active? }, + if: Proc.new { User.current.admin? }, caption: :project_module_storages, icon: 'icon2 icon-hosting' menu :project_menu, :settings_projects_storages, { controller: '/storages/admin/projects_storages', action: 'index' }, - if: Proc.new { OpenProject::FeatureDecisions.storages_module_active? }, caption: :project_module_storages, parent: :settings end diff --git a/modules/storages/spec/contracts/storages/file_links/create_contract_spec.rb b/modules/storages/spec/contracts/storages/file_links/create_contract_spec.rb index 9042fa4b91..ae3a479ab9 100644 --- a/modules/storages/spec/contracts/storages/file_links/create_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/file_links/create_contract_spec.rb @@ -31,7 +31,7 @@ require_module_spec_helper require 'contracts/shared/model_contract_shared_context' require_relative 'shared_contract_examples' -describe Storages::FileLinks::CreateContract, with_flag: { storages_module_active: true } do +describe Storages::FileLinks::CreateContract do include_context 'ModelContract shared context' it_behaves_like 'file_link contract' do diff --git a/modules/storages/spec/contracts/storages/file_links/delete_contract_spec.rb b/modules/storages/spec/contracts/storages/file_links/delete_contract_spec.rb index 08ad5ced0e..854bb379d1 100644 --- a/modules/storages/spec/contracts/storages/file_links/delete_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/file_links/delete_contract_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_module_spec_helper require 'contracts/shared/model_contract_shared_context' -describe ::Storages::FileLinks::DeleteContract, with_flag: { storages_module_active: true } do +describe ::Storages::FileLinks::DeleteContract do include_context 'ModelContract shared context' let(:current_user) { create(:user) } diff --git a/modules/storages/spec/contracts/storages/project_storages/create_contract_spec.rb b/modules/storages/spec/contracts/storages/project_storages/create_contract_spec.rb index 58be94e376..3147cc1f31 100644 --- a/modules/storages/spec/contracts/storages/project_storages/create_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/project_storages/create_contract_spec.rb @@ -31,7 +31,7 @@ require_module_spec_helper require 'contracts/shared/model_contract_shared_context' require_relative 'shared_contract_examples' -describe Storages::ProjectStorages::CreateContract, with_flag: { storages_module_active: true } do +describe Storages::ProjectStorages::CreateContract do include_context 'ModelContract shared context' it_behaves_like 'ProjectStorages contract' do diff --git a/modules/storages/spec/contracts/storages/project_storages/delete_contract_spec.rb b/modules/storages/spec/contracts/storages/project_storages/delete_contract_spec.rb index 9cbbcba8c5..efa97711fa 100644 --- a/modules/storages/spec/contracts/storages/project_storages/delete_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/project_storages/delete_contract_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_module_spec_helper require 'contracts/shared/model_contract_shared_context' -describe ::Storages::ProjectStorages::DeleteContract, with_flag: { storages_module_active: true } do +describe ::Storages::ProjectStorages::DeleteContract do include_context 'ModelContract shared context' let(:current_user) { create(:user) } diff --git a/modules/storages/spec/contracts/storages/storages/base_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/base_contract_spec.rb index 1eb1670676..7c165db41c 100644 --- a/modules/storages/spec/contracts/storages/storages/base_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/storages/base_contract_spec.rb @@ -28,7 +28,7 @@ require_relative '../../../spec_helper' -describe Storages::Storages::BaseContract, :storage_server_helpers, with_flag: { storages_module_active: true }, webmock: true do +describe Storages::Storages::BaseContract, :storage_server_helpers, webmock: true do let(:current_user) { create(:admin) } let(:storage_host) { 'https://host1.example.com' } let(:storage) { build(:storage, host: storage_host) } diff --git a/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb index 84d1b6aef5..70d58c5c8c 100644 --- a/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb @@ -31,7 +31,7 @@ require_module_spec_helper require 'contracts/shared/model_contract_shared_context' require_relative 'shared_contract_examples' -describe Storages::Storages::CreateContract, with_flag: { storages_module_active: true } do +describe Storages::Storages::CreateContract do include_context 'ModelContract shared context' it_behaves_like 'storage contract' do diff --git a/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb index 197a2ccc2b..84069a4014 100644 --- a/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_module_spec_helper require 'contracts/shared/model_contract_shared_context' -describe ::Storages::Storages::DeleteContract, with_flag: { storages_module_active: true } do +describe ::Storages::Storages::DeleteContract do include_context 'ModelContract shared context' let(:storage) { create(:storage) } diff --git a/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb index cf794325bf..f2e8b72e6d 100644 --- a/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb +++ b/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb @@ -31,7 +31,7 @@ require_module_spec_helper require 'contracts/shared/model_contract_shared_context' require_relative 'shared_contract_examples' -describe ::Storages::Storages::UpdateContract, with_flag: { storages_module_active: true } do +describe ::Storages::Storages::UpdateContract do include_context 'ModelContract shared context' it_behaves_like 'storage contract' do diff --git a/modules/storages/spec/controller/storages_controller_spec.rb b/modules/storages/spec/controller/storages_controller_spec.rb index aa27084489..0b112aa5b5 100644 --- a/modules/storages/spec/controller/storages_controller_spec.rb +++ b/modules/storages/spec/controller/storages_controller_spec.rb @@ -30,7 +30,7 @@ require_relative '../spec_helper' # These specs mainly check that error messages from a sub-service # (about unsafe hosts with HTTP protocol) are passed to the main form. -describe ::Storages::Admin::StoragesController, with_flag: { storages_module_active: true }, webmock: true, type: :controller do +describe ::Storages::Admin::StoragesController, webmock: true, type: :controller do render_views # rendering views is stubbed by default in controller specs include StorageServerHelpers diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb index c65e5cd7c3..cb16af25ec 100644 --- a/modules/storages/spec/features/admin_storages_spec.rb +++ b/modules/storages/spec/features/admin_storages_spec.rb @@ -28,7 +28,7 @@ require_relative '../spec_helper' -describe 'Admin storages', :storage_server_helpers, with_flag: { storages_module_active: true }, type: :feature, js: true do +describe 'Admin storages', :storage_server_helpers, type: :feature, js: true do let(:admin) { create(:admin) } before do diff --git a/modules/storages/spec/features/create_and_delete_project_storage_spec.rb b/modules/storages/spec/features/create_and_delete_project_storage_spec.rb index 79cfe9321e..dce858eda7 100644 --- a/modules/storages/spec/features/create_and_delete_project_storage_spec.rb +++ b/modules/storages/spec/features/create_and_delete_project_storage_spec.rb @@ -31,7 +31,7 @@ require_relative '../spec_helper' # Setup storages in Project -> Settings -> File Storages # This tests assumes that a Storage has already been setup # in the Admin section, tested by admin_storage_spec.rb. -describe 'Activation of storages in projects', with_flag: { storages_module_active: true }, type: :feature, js: true do +describe 'Activation of storages in projects', type: :feature, js: true do let(:user) { create(:user) } # The first page is the Project -> Settings -> General page, so we need # to provide the user with the edit_project permission in the role. diff --git a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb index 2046915afc..64f15f314d 100644 --- a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb +++ b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb @@ -30,7 +30,7 @@ require_relative '../spec_helper' # Test if the deletion of a ProjectStorage actually deletes related FileLink # objects. -describe 'Delete ProjectStorage with FileLinks', with_flag: { storages_module_active: true }, type: :feature, js: true do +describe 'Delete ProjectStorage with FileLinks', type: :feature, js: true do let(:user) { create(:user) } let(:role) { create(:existing_role, permissions: [:manage_storages_in_project]) } let(:project) do diff --git a/modules/storages/spec/features/storages_module_disabled_spec.rb b/modules/storages/spec/features/ensure_storages_module_spec.rb similarity index 57% rename from modules/storages/spec/features/storages_module_disabled_spec.rb rename to modules/storages/spec/features/ensure_storages_module_spec.rb index c94b029b40..2b6948c774 100644 --- a/modules/storages/spec/features/storages_module_disabled_spec.rb +++ b/modules/storages/spec/features/ensure_storages_module_spec.rb @@ -28,10 +28,7 @@ require_relative '../spec_helper' -# Checks that disabling storages modules hides everything related to it in web -# interface. Enable it first, check everything present, then disable it, and -# check everything present. -describe 'Disablement of storages module', type: :feature, js: true do +describe 'Ensure storages module', type: :feature, js: true do current_user { create(:admin) } let(:role) do @@ -59,70 +56,61 @@ describe 'Disablement of storages module', type: :feature, js: true do Capybara.raise_server_errors = old_value end - it 'removes storages from administration and project pages' do - Setting.feature_storages_module_active = true + it 'shows storages on administration and project pages' do expect_pages_to_include_storages_information - Setting.feature_storages_module_active = false - expect_pages_not_to_include_storages_information end def expect_pages_to_include_storages_information - run_administration_pages_assertions_about_storages_visibility(expectation_target: :to) - run_project_pages_assertions_about_storages_visibility(expectation_target: :to) - run_permissions_pages_assertions_about_storages_visibility(expectation_target: :to) + run_administration_pages_assertions_about_storages_visibility + run_project_pages_assertions_about_storages_visibility + run_permissions_pages_assertions_about_storages_visibility end - def expect_pages_not_to_include_storages_information - run_administration_pages_assertions_about_storages_visibility(expectation_target: :not_to) - run_project_pages_assertions_about_storages_visibility(expectation_target: :not_to) - run_permissions_pages_assertions_about_storages_visibility(expectation_target: :not_to) - end - - def run_administration_pages_assertions_about_storages_visibility(expectation_target:) + def run_administration_pages_assertions_about_storages_visibility visit admin_index_path within '#menu-sidebar' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end visit admin_settings_projects_path within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end visit admin_settings_storages_path - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end - def run_project_pages_assertions_about_storages_visibility(expectation_target:) + def run_project_pages_assertions_about_storages_visibility visit project_settings_modules_path(project) within '#menu-sidebar' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages))) + expect(page).to have_text(I18n.t(:project_module_storages)) end visit project_settings_projects_storages_path(project) - expect(page).send(expectation_target, have_text(I18n.t('storages.page_titles.project_settings.index'))) + expect(page).to have_text(I18n.t('storages.page_titles.project_settings.index')) end - def run_permissions_pages_assertions_about_storages_visibility(expectation_target:) + def run_permissions_pages_assertions_about_storages_visibility visit new_role_path within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages).upcase)) + expect(page).to have_text(I18n.t(:project_module_storages).upcase) end visit edit_role_path(role) within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages).upcase)) + expect(page).to have_text(I18n.t(:project_module_storages).upcase) end visit report_roles_path(role) within '#content' do - expect(page).send(expectation_target, have_text(I18n.t(:project_module_storages).upcase)) + expect(page).to have_text(I18n.t(:project_module_storages).upcase) end end end diff --git a/modules/storages/spec/features/show_file_links_spec.rb b/modules/storages/spec/features/show_file_links_spec.rb index 4a9f136e96..eb00334374 100644 --- a/modules/storages/spec/features/show_file_links_spec.rb +++ b/modules/storages/spec/features/show_file_links_spec.rb @@ -28,7 +28,7 @@ require_relative '../spec_helper' -describe 'Showing of file links in work package', with_flag: { storages_module_active: true }, type: :feature, js: true do +describe 'Showing of file links in work package', type: :feature, js: true do let(:permissions) { %i(view_work_packages edit_work_packages view_file_links manage_file_links) } let(:project) { create(:project) } let(:current_user) { create(:user, member_in_project: project, member_with_permissions: permissions) } diff --git a/modules/storages/spec/permissions/manage_storage_in_project_spec.rb b/modules/storages/spec/permissions/manage_storage_in_project_spec.rb index 45f3812863..f44340c5a2 100644 --- a/modules/storages/spec/permissions/manage_storage_in_project_spec.rb +++ b/modules/storages/spec/permissions/manage_storage_in_project_spec.rb @@ -31,10 +31,7 @@ require 'support/permission_specs' require_module_spec_helper # rubocop:disable RSpec/EmptyExampleGroup -describe Storages::Admin::ProjectsStoragesController, - 'manage_storage_in_project permission', - with_flag: { storages_module_active: true }, - type: :controller do +describe Storages::Admin::ProjectsStoragesController, 'manage_storage_in_project permission', type: :controller do include PermissionSpecs controller_actions.each do |action| diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb index 37ae2583b3..bf7c6877b2 100644 --- a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb +++ b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' require_module_spec_helper -describe 'API v3 file links resource', with_flag: { storages_module_active: true }, type: :request do +describe 'API v3 file links resource', type: :request do include API::V3::Utilities::PathHelper let(:permissions) { %i(view_work_packages view_file_links) } @@ -122,10 +122,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true end end - context 'if storages feature is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end - describe 'with filter by storage' do let!(:another_project_storage) { create(:project_storage, project:, storage: another_storage) } let(:path) { "#{api_v3_paths.file_links(work_package.id)}?filters=#{CGI.escape(filters.to_json)}" } @@ -217,10 +213,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true end end end - - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end end context 'when some embedded file link elements are NOT valid' do @@ -412,10 +404,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true it_behaves_like 'not found' end - - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end end describe 'DELETE /api/v3/file_links/:file_link_id' do @@ -449,10 +437,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true it_behaves_like 'not found' end - - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end end describe 'GET /api/v3/file_links/:file_link_id/open' do @@ -485,10 +469,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true it_behaves_like 'not found' end - - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end end describe 'GET /api/v3/file_links/:file_link_id/download' do diff --git a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb index 3cb283ca6e..20b5386a71 100644 --- a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb +++ b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_module_spec_helper # We want to check the case of file_links from multiple storages -describe 'API v3 file links resource', with_flag: { storages_module_active: true }, type: :request do +describe 'API v3 file links resource', type: :request do include API::V3::Utilities::PathHelper let(:project) { create(:project) } diff --git a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb index fc827584c7..6ad62395ce 100644 --- a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb +++ b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' require_module_spec_helper -describe 'API v3 storages resource', with_flag: { storages_module_active: true }, type: :request, content_type: :json do +describe 'API v3 storages resource', type: :request, content_type: :json do include API::V3::Utilities::PathHelper let(:permissions) { %i(view_work_packages view_file_links) } @@ -106,10 +106,6 @@ describe 'API v3 storages resource', with_flag: { storages_module_active: true } it_behaves_like 'successful storage response' end - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'not found' - end - context 'when OAuth authorization server is involved' do shared_examples 'a storage authorization result' do |expected:, has_authorize_link:| subject { last_response.body } diff --git a/modules/storages/spec/requests/api/v3/work_packages/shared_filter_examples.rb b/modules/storages/spec/requests/api/v3/work_packages/shared_filter_examples.rb deleted file mode 100644 index 68b3bbce81..0000000000 --- a/modules/storages/spec/requests/api/v3/work_packages/shared_filter_examples.rb +++ /dev/null @@ -1,38 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2022 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. -#++ - -require 'spec_helper' - -shared_examples_for 'filter unavailable when storages module is inactive' do - context 'when storages module is inactive', with_flag: { storages_module_active: false } do - it_behaves_like 'error response', - 400, - 'InvalidQuery', - 'filter does not exist.' - end -end diff --git a/modules/storages/spec/requests/api/v3/work_packages/work_packages_linkable_filter_spec.rb b/modules/storages/spec/requests/api/v3/work_packages/work_packages_linkable_filter_spec.rb index 8e41612a04..ac0f7ce27a 100644 --- a/modules/storages/spec/requests/api/v3/work_packages/work_packages_linkable_filter_spec.rb +++ b/modules/storages/spec/requests/api/v3/work_packages/work_packages_linkable_filter_spec.rb @@ -28,10 +28,8 @@ require 'spec_helper' require_module_spec_helper -require_relative 'shared_filter_examples' describe 'API v3 work packages resource with filters for the linkable to storage attribute', - with_flag: { storages_module_active: true }, type: :request, content_type: :json do include API::V3::Utilities::PathHelper @@ -123,8 +121,6 @@ describe 'API v3 work packages resource with filters for the linkable to storage let(:elements) { [] } end end - - include_examples 'filter unavailable when storages module is inactive' end context 'with filter for storage url' do @@ -167,8 +163,6 @@ describe 'API v3 work packages resource with filters for the linkable to storage let(:elements) { [] } end end - - include_examples 'filter unavailable when storages module is inactive' end end end diff --git a/modules/storages/spec/requests/api/v3/work_packages/work_packages_linked_filter_spec.rb b/modules/storages/spec/requests/api/v3/work_packages/work_packages_linked_filter_spec.rb index 0561601326..29f70eaa51 100644 --- a/modules/storages/spec/requests/api/v3/work_packages/work_packages_linked_filter_spec.rb +++ b/modules/storages/spec/requests/api/v3/work_packages/work_packages_linked_filter_spec.rb @@ -28,10 +28,8 @@ require 'spec_helper' require_module_spec_helper -require_relative 'shared_filter_examples' describe 'API v3 work packages resource with filters for linked storage file', - with_flag: { storages_module_active: true }, type: :request, content_type: :json do include API::V3::Utilities::PathHelper @@ -139,8 +137,6 @@ describe 'API v3 work packages resource with filters for linked storage file', end end - include_examples 'filter unavailable when storages module is inactive' - context 'if using signaling' do let(:path) { api_v3_paths.path_for :work_packages, select: 'total,count,_type,elements/*', filters: } @@ -182,8 +178,6 @@ describe 'API v3 work packages resource with filters for linked storage file', let(:elements) { [] } end end - - include_examples 'filter unavailable when storages module is inactive' end context 'with single filter for storage url' do @@ -226,8 +220,6 @@ describe 'API v3 work packages resource with filters for linked storage file', let(:elements) { [] } end end - - include_examples 'filter unavailable when storages module is inactive' end context 'with combined filter of file id and storage id' do diff --git a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb index e72f2ca7ad..e1fcb6765c 100644 --- a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb +++ b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_module_spec_helper require 'services/base_services/behaves_like_delete_service' -describe ::Storages::ProjectStorages::DeleteService, with_flag: { storages_module_active: true }, type: :model do +describe ::Storages::ProjectStorages::DeleteService, type: :model do context 'with records written to DB' do let(:user) { create(:user) } let(:role) { create(:existing_role, permissions: [:manage_storages_in_project]) } diff --git a/spec/features/menu_items/admin_menu_item_spec.rb b/spec/features/menu_items/admin_menu_item_spec.rb index 9ad032651e..3e45e69c45 100644 --- a/spec/features/menu_items/admin_menu_item_spec.rb +++ b/spec/features/menu_items/admin_menu_item_spec.rb @@ -44,8 +44,8 @@ describe 'Admin menu items', js: true do visit admin_index_path expect(page).to have_selector('[data-qa-selector="menu-blocks--container"]') - expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 18) - expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 19) # All plus 'overview' + expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 19) + expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 20) # All plus 'overview' end end @@ -57,10 +57,10 @@ describe 'Admin menu items', js: true do visit admin_index_path expect(page).to have_selector('[data-qa-selector="menu-blocks--container"]') - expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 17) + expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 18) expect(page).not_to have_selector('[data-qa-selector="menu-block"]', text: I18n.t('timelines.admin_menu.colors')) - expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 18) # All plus 'overview' + expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 19) # All plus 'overview' expect(page).not_to have_selector('[data-qa-selector="op-menu--item-action"]', text: I18n.t('timelines.admin_menu.colors')) end end diff --git a/spec/requests/oauth_clients/callback_flow_spec.rb b/spec/requests/oauth_clients/callback_flow_spec.rb index a3bdc757d4..77e84a4ee0 100644 --- a/spec/requests/oauth_clients/callback_flow_spec.rb +++ b/spec/requests/oauth_clients/callback_flow_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' require 'rack/test' -describe 'OAuthClient callback endpoint', with_flag: { storages_module_active: true }, type: :request do +describe 'OAuthClient callback endpoint', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper diff --git a/spec/support/shared/with_settings.rb b/spec/support/shared/with_settings.rb index 6206cd03bb..b1c14e7633 100644 --- a/spec/support/shared/with_settings.rb +++ b/spec/support/shared/with_settings.rb @@ -39,8 +39,6 @@ def aggregate_mocked_settings(example, settings) end RSpec.shared_context 'with settings reset' do - let(:storages_module_active) { true } - around do |example| definitions_before = Settings::Definition.all.dup Settings::Definition.send(:reset) @@ -49,10 +47,6 @@ RSpec.shared_context 'with settings reset' do Settings::Definition.send(:reset) Settings::Definition.instance_variable_set(:@all, definitions_before) end - - before do - allow(OpenProject::FeatureDecisions).to receive(:storages_module_active?).and_return(storages_module_active) - end end module WithSettingsMixin