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

disable storages module by default through feature_storages_module_active setting

Christophe Bliard8e242e95aae5
diff --git a/config/constants/settings/definitions.rb b/config/constants/settings/definitions.rb
index a143c16974c..709385183de 100644
--- a/config/constants/settings/definitions.rb
+++ b/config/constants/settings/definitions.rb
@@ -387,6 +387,10 @@ Settings::Definition.define do
value: 'enterprise-on-premises---euro---1-year',
writable: false
+ add :feature_storages_module_active,
+ value: false,
+ format: :boolean
+
add :feeds_enabled,
value: true
diff --git a/lib/open_project/feature_decisions.rb b/lib/open_project/feature_decisions.rb
new file mode 100644
index 00000000000..a3b49b1f482
--- /dev/null
+++ b/lib/open_project/feature_decisions.rb
@@ -0,0 +1,35 @@
+#-- 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 OpenProject
+ module FeatureDecisions
+ def self.storages_module_active?
+ Setting.feature_storages_module_active
+ end
+ end
+end
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 9a3c5e7e54a..13107d1761c 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -50,7 +50,9 @@ module OpenProject::Storages
name: 'OpenProject Storages' do
# 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 do
+ project_module :storages,
+ dependencies: :work_package_tracking,
+ if: ->(*) { OpenProject::FeatureDecisions.storages_module_active? } do
permission :view_file_links,
{},
dependencies: %i[view_work_packages]
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 4374b41e809..c43e1cbb133 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
@@ -27,10 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
require_relative 'shared_contract_examples'
-describe Storages::FileLinks::CreateContract do
+describe Storages::FileLinks::CreateContract, :enable_storages 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 962f03d6852..9561f4993db 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
@@ -27,9 +27,10 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
-describe ::Storages::FileLinks::DeleteContract do
+describe ::Storages::FileLinks::DeleteContract, :enable_storages 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 1deb3f60078..4f5e7aa8d64 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
@@ -27,10 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
require_relative 'shared_contract_examples'
-describe Storages::ProjectStorages::CreateContract do
+describe Storages::ProjectStorages::CreateContract, :enable_storages 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 dbd99d1147a..b7b4772085e 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
@@ -27,9 +27,10 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
-describe ::Storages::ProjectStorages::DeleteContract do
+describe ::Storages::ProjectStorages::DeleteContract, :enable_storages 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 3906477e948..7a939606d2e 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, webmock: true do
+describe Storages::Storages::BaseContract, :enable_storages, :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 164259c7b0a..a4eee44beeb 100644
--- a/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/create_contract_spec.rb
@@ -27,10 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
require_relative 'shared_contract_examples'
-describe Storages::Storages::CreateContract do
+describe Storages::Storages::CreateContract, :enable_storages 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 10bddf26471..0453a041201 100644
--- a/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb
@@ -27,9 +27,10 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
-describe ::Storages::Storages::DeleteContract do
+describe ::Storages::Storages::DeleteContract, :enable_storages 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 da1a56d2e84..2a86c22de40 100644
--- a/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/update_contract_spec.rb
@@ -27,10 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'contracts/shared/model_contract_shared_context'
require_relative 'shared_contract_examples'
-describe ::Storages::Storages::UpdateContract do
+describe ::Storages::Storages::UpdateContract, :enable_storages do
include_context 'ModelContract shared context'
it_behaves_like 'storage contract' do
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index 95c0dcdd29d..434710e6a05 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, type: :feature, js: true do
+describe 'Admin storages', :enable_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 754919d4264..4425abc5e4b 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', type: :feature, js: true do
+describe 'Activation of storages in projects', :enable_storages, 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 aa61ec47573..db50a3ac731 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', type: :feature, js: true do
+describe 'Delete ProjectStorage with FileLinks', :enable_storages, 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/permissions/manage_storage_in_project_spec.rb b/modules/storages/spec/permissions/manage_storage_in_project_spec.rb
index 0aa6b6a1245..f3253be9050 100644
--- a/modules/storages/spec/permissions/manage_storage_in_project_spec.rb
+++ b/modules/storages/spec/permissions/manage_storage_in_project_spec.rb
@@ -28,11 +28,17 @@
require 'spec_helper'
require 'support/permission_specs'
+require_module_spec_helper
-describe Storages::Admin::ProjectsStoragesController, 'manage_storage_in_project permission', type: :controller do
+# rubocop:disable RSpec/EmptyExampleGroup
+describe Storages::Admin::ProjectsStoragesController,
+ 'manage_storage_in_project permission',
+ :enable_storages,
+ type: :controller do
include PermissionSpecs
controller_actions.each do |action|
check_permission_required_for("#{described_class.controller_path}##{action}", :manage_storages_in_project)
end
end
+# rubocop:enable RSpec/EmptyExampleGroup
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 119b6dbca13..dd100cda925 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
@@ -27,9 +27,10 @@
#++
require 'spec_helper'
+require_module_spec_helper
# rubocop:disable RSpec/MultipleMemoizedHelpers
-describe 'API v3 file links resource', type: :request do
+describe 'API v3 file links resource', :enable_storages, type: :request do
include API::V3::Utilities::PathHelper
let(:permissions) { %i(view_work_packages view_file_links) }
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 03ae5650a54..df59cc3123a 100644
--- a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
+++ b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
@@ -27,8 +27,9 @@
#++
require 'spec_helper'
+require_module_spec_helper
-describe 'API v3 storages resource', type: :request, content_type: :json do
+describe 'API v3 storages resource', :enable_storages, type: :request, content_type: :json do
include API::V3::Utilities::PathHelper
let(:permissions) { %i(view_file_links) }
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 57ea1d9fb43..4bb50b637af 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
@@ -27,9 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
# rubocop:disable RSpec/MultipleMemoizedHelpers
describe 'API v3 work packages resource with filters for the linkable to storage attribute',
+ :enable_storages,
type: :request,
content_type: :json do
include API::V3::Utilities::PathHelper
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 df8992c633b..13fa6462e14 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
@@ -27,9 +27,11 @@
#++
require 'spec_helper'
+require_module_spec_helper
# rubocop:disable RSpec/MultipleMemoizedHelpers
describe 'API v3 work packages resource with filters for linked storage file',
+ :enable_storages,
type: :request,
content_type: :json do
include API::V3::Utilities::PathHelper
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 a69709e1bd0..15d8575afd5 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
@@ -27,9 +27,10 @@
#++
require 'spec_helper'
+require_module_spec_helper
require 'services/base_services/behaves_like_delete_service'
-describe ::Storages::ProjectStorages::DeleteService, type: :model do
+describe ::Storages::ProjectStorages::DeleteService, :enable_storages, 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/modules/storages/spec/support/enable_storages_module.rb b/modules/storages/spec/support/enable_storages_module.rb
new file mode 100644
index 00000000000..7c11aa48f9b
--- /dev/null
+++ b/modules/storages/spec/support/enable_storages_module.rb
@@ -0,0 +1,9 @@
+RSpec.shared_context "with storages module enabled" do
+ before do
+ allow(OpenProject::FeatureDecisions).to receive(:storages_module_active?).and_return(true)
+ end
+end
+
+RSpec.configure do |rspec|
+ rspec.include_context "with storages module enabled", enable_storages: true
+end
diff --git a/spec/support/module_spec_helper.rb b/spec/support/module_spec_helper.rb
new file mode 100644
index 00000000000..84a9e4781bc
--- /dev/null
+++ b/spec/support/module_spec_helper.rb
@@ -0,0 +1,37 @@
+#-- 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+# load the module spec_helper.rb from calling spec if it exists
+def require_module_spec_helper
+ module_caller = caller.grep(Regexp.new("\\A#{Rails.root.join('modules')}")).first
+ return unless module_caller
+
+ module_name = module_caller.scan(/modules\/\w+/).first
+ module_spec_helper = Rails.root.join("#{module_name}/spec/spec_helper.rb")
+ require module_spec_helper if module_spec_helper.file?
+end