diff --git a/config/initializers/module_handler.rb b/config/initializers/module_handler.rb index 6960d30c64..4a58246037 100644 --- a/config/initializers/module_handler.rb +++ b/config/initializers/module_handler.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 diff --git a/lib/open_project/plugins/module_handler.rb b/lib/open_project/plugins/module_handler.rb index 342cb2cd51..86d0074af2 100644 --- a/lib/open_project/plugins/module_handler.rb +++ b/lib/open_project/plugins/module_handler.rb @@ -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 diff --git a/spec/lib/open_project/plugins/module_handler_spec.rb b/spec/lib/open_project/plugins/module_handler_spec.rb index e2d859a763..a2b6ed51bb 100644 --- a/spec/lib/open_project/plugins/module_handler_spec.rb +++ b/spec/lib/open_project/plugins/module_handler_spec.rb @@ -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