From e6f2e3385684ba95167a6728c9df95413a841e06 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sun, 10 Dec 2023 03:34:16 +0000 Subject: [PATCH] Allows configure plugins directory path in order to change the default location in test environment (#36320). Patch by @tohosaku. git-svn-id: https://svn.redmine.org/redmine/trunk@22507 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/application.rb | 3 +++ config/environments/test.rb | 3 +++ lib/redmine/plugin_loader.rb | 2 +- test/unit/lib/redmine/plugin_loader_test.rb | 3 ++- test/unit/lib/redmine/plugin_test.rb | 3 +-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/application.rb b/config/application.rb index 48e855c9b..f5062dfe7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -85,6 +85,9 @@ module RedmineApp # for more options (same options as config.cache_store). config.redmine_search_cache_store = :memory_store + # Sets default plugin directory + config.redmine_plugin_directory = 'plugins' + # Configure log level here so that additional environment file # can change it (environments/ENV.rb would take precedence over it) config.log_level = Rails.env.production? ? :info : :debug diff --git a/config/environments/test.rb b/config/environments/test.rb index 199f1bb27..e67cea76c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -18,6 +18,9 @@ Rails.application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false + # Change the plugin directory when testing to avoid clashes with real plugins. + config.redmine_plugin_directory = 'test/fixtures/plugins' + # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { diff --git a/lib/redmine/plugin_loader.rb b/lib/redmine/plugin_loader.rb index 135df09ba..04d7e4af0 100644 --- a/lib/redmine/plugin_loader.rb +++ b/lib/redmine/plugin_loader.rb @@ -84,7 +84,7 @@ module Redmine class PluginLoader # Absolute path to the directory where plugins are located cattr_accessor :directory - self.directory = Rails.root.join('plugins') + self.directory = Rails.root.join Rails.application.config.redmine_plugin_directory # Absolute path to the public directory where plugins assets are copied cattr_accessor :public_directory diff --git a/test/unit/lib/redmine/plugin_loader_test.rb b/test/unit/lib/redmine/plugin_loader_test.rb index ed5943346..458460986 100644 --- a/test/unit/lib/redmine/plugin_loader_test.rb +++ b/test/unit/lib/redmine/plugin_loader_test.rb @@ -23,8 +23,9 @@ class Redmine::PluginLoaderTest < ActiveSupport::TestCase def setup clear_public + # Change plugin directory for testing to default in config/environments/tesr.rb. + # plugins/foo => test/fixtures/plugins/foo @klass = Redmine::PluginLoader - @klass.directory = Rails.root.join('test/fixtures/plugins') @klass.public_directory = Rails.root.join('tmp/public/plugin_assets') @klass.load end diff --git a/test/unit/lib/redmine/plugin_test.rb b/test/unit/lib/redmine/plugin_test.rb index 02df23236..9cfd7e7da 100644 --- a/test/unit/lib/redmine/plugin_test.rb +++ b/test/unit/lib/redmine/plugin_test.rb @@ -22,9 +22,8 @@ require_relative '../../../test_helper' class Redmine::PluginTest < ActiveSupport::TestCase def setup @klass = Redmine::Plugin - # Change plugin directory for testing to default + # Change plugin directory for testing to default in config/environments/test.rb. # plugins/foo => test/fixtures/plugins/foo - @klass.directory = Rails.root.join('test/fixtures/plugins') # In case some real plugins are installed @klass.clear -- 2.39.5