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

Simplify the OpenProject::Plugins::ModuleHandler class

Dombi Attila4549de8ffacb
diff --git a/config/initializers/module_handler.rb b/config/initializers/module_handler.rb
index 95e688feb5a..4a582460370 100644
--- a/config/initializers/module_handler.rb
+++ b/config/initializers/module_handler.rb
@@ -29,7 +29,6 @@
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.enforce!
+ 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 7b90fcea47f..86d0074af2d 100644
--- a/lib/open_project/plugins/module_handler.rb
+++ b/lib/open_project/plugins/module_handler.rb
@@ -31,12 +31,8 @@ module OpenProject::Plugins
@@disabled_modules = []
class << self
- def disable_modules(module_names)
- @@disabled_modules += Array(module_names).map(&:to_sym)
- end
-
- def enforce!
- @@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
diff --git a/spec/lib/open_project/plugins/module_handler_spec.rb b/spec/lib/open_project/plugins/module_handler_spec.rb
index e2d859a763d..a2b6ed51bb8 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