Merge pull request #11012 from opf/fix/43213/reloading-disabled-modules

Prevent stripping of permissions before disabled modules registered
pull/11019/head
Dombi Attila 2 years ago committed by GitHub
commit 365dc01f3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      config/initializers/module_handler.rb
  2. 12
      lib/open_project/plugins/module_handler.rb
  3. 3
      spec/lib/open_project/plugins/module_handler_spec.rb

@ -26,9 +26,9 @@
# See COPYRIGHT and LICENSE files for more details.
#++
Rails.application.config.after_initialize do
Rails.application.config.to_prepare do
if OpenProject::Configuration.disabled_modules.any?
to_disable = OpenProject::Configuration.disabled_modules
OpenProject::Plugins::ModuleHandler.disable_modules(to_disable)
OpenProject::Plugins::ModuleHandler.disable_modules!(to_disable)
end
end

@ -31,19 +31,11 @@ module OpenProject::Plugins
@@disabled_modules = []
class << self
def disable_modules(module_names)
@@disabled_modules += Array(module_names).map(&:to_sym)
end
def disable(disabled_modules)
disabled_modules.map do |module_name|
def disable_modules!(module_names)
@@disabled_modules += Array(module_names).map(&:to_sym).each do |module_name|
OpenProject::AccessControl.remove_modules_permissions(module_name)
end
end
end
OpenProject::Application.config.to_prepare do
OpenProject::Plugins::ModuleHandler.disable(@@disabled_modules)
end
end
end

@ -31,8 +31,7 @@ describe OpenProject::Plugins::ModuleHandler do
let!(:all_former_permissions) { OpenProject::AccessControl.permissions }
before do
disabled_modules = OpenProject::Plugins::ModuleHandler.disable_modules('repository')
OpenProject::Plugins::ModuleHandler.disable(disabled_modules)
described_class.disable_modules!('repository')
end
after do

Loading…
Cancel
Save