disable storages module by default through feature_storages_module_active setting

pull/10417/head
Christophe Bliard 3 years ago
parent 76f9aa760d
commit 8e242e95aa
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 4
      config/constants/settings/definitions.rb
  2. 35
      lib/open_project/feature_decisions.rb
  3. 4
      modules/storages/lib/open_project/storages/engine.rb
  4. 3
      modules/storages/spec/contracts/storages/file_links/create_contract_spec.rb
  5. 3
      modules/storages/spec/contracts/storages/file_links/delete_contract_spec.rb
  6. 3
      modules/storages/spec/contracts/storages/project_storages/create_contract_spec.rb
  7. 3
      modules/storages/spec/contracts/storages/project_storages/delete_contract_spec.rb
  8. 2
      modules/storages/spec/contracts/storages/storages/base_contract_spec.rb
  9. 3
      modules/storages/spec/contracts/storages/storages/create_contract_spec.rb
  10. 3
      modules/storages/spec/contracts/storages/storages/delete_contract_spec.rb
  11. 3
      modules/storages/spec/contracts/storages/storages/update_contract_spec.rb
  12. 2
      modules/storages/spec/features/admin_storages_spec.rb
  13. 2
      modules/storages/spec/features/create_and_delete_project_storage_spec.rb
  14. 2
      modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb
  15. 8
      modules/storages/spec/permissions/manage_storage_in_project_spec.rb
  16. 3
      modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
  17. 3
      modules/storages/spec/requests/api/v3/storages/storages_spec.rb
  18. 2
      modules/storages/spec/requests/api/v3/work_packages/work_packages_linkable_filter_spec.rb
  19. 2
      modules/storages/spec/requests/api/v3/work_packages/work_packages_linked_filter_spec.rb
  20. 3
      modules/storages/spec/services/storages/project_storages/delete_service_spec.rb
  21. 9
      modules/storages/spec/support/enable_storages_module.rb
  22. 37
      spec/support/module_spec_helper.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

@ -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

@ -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]

@ -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

@ -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) }

@ -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

@ -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) }

@ -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) }

@ -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

@ -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) }

@ -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

@ -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

@ -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.

@ -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

@ -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

@ -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) }

@ -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) }

@ -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

@ -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

@ -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]) }

@ -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

@ -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
Loading…
Cancel
Save