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
This commit is contained in:
Marius Balteanu
2023-12-10 03:34:16 +00:00
parent ac36333e90
commit e6f2e33856
5 changed files with 10 additions and 4 deletions

View File

@@ -85,6 +85,9 @@ module RedmineApp
# for more options (same options as config.cache_store). # for more options (same options as config.cache_store).
config.redmine_search_cache_store = :memory_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 # Configure log level here so that additional environment file
# can change it (environments/ENV.rb would take precedence over it) # can change it (environments/ENV.rb would take precedence over it)
config.log_level = Rails.env.production? ? :info : :debug config.log_level = Rails.env.production? ? :info : :debug

View File

@@ -18,6 +18,9 @@ Rails.application.configure do
# preloads Rails for running tests, you may have to set it to true. # preloads Rails for running tests, you may have to set it to true.
config.eager_load = false 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. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {

View File

@@ -84,7 +84,7 @@ module Redmine
class PluginLoader class PluginLoader
# Absolute path to the directory where plugins are located # Absolute path to the directory where plugins are located
cattr_accessor :directory 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 # Absolute path to the public directory where plugins assets are copied
cattr_accessor :public_directory cattr_accessor :public_directory

View File

@@ -23,8 +23,9 @@ class Redmine::PluginLoaderTest < ActiveSupport::TestCase
def setup def setup
clear_public clear_public
# Change plugin directory for testing to default in config/environments/tesr.rb.
# plugins/foo => test/fixtures/plugins/foo
@klass = Redmine::PluginLoader @klass = Redmine::PluginLoader
@klass.directory = Rails.root.join('test/fixtures/plugins')
@klass.public_directory = Rails.root.join('tmp/public/plugin_assets') @klass.public_directory = Rails.root.join('tmp/public/plugin_assets')
@klass.load @klass.load
end end

View File

@@ -22,9 +22,8 @@ require_relative '../../../test_helper'
class Redmine::PluginTest < ActiveSupport::TestCase class Redmine::PluginTest < ActiveSupport::TestCase
def setup def setup
@klass = Redmine::Plugin @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 # plugins/foo => test/fixtures/plugins/foo
@klass.directory = Rails.root.join('test/fixtures/plugins')
# In case some real plugins are installed # In case some real plugins are installed
@klass.clear @klass.clear