Feature #36320 » 0001-Fix-autoloading-plugin-classes.patch
| config/environments/test.rb | ||
|---|---|---|
|
# preloads Rails for running tests, you may have to set it to true.
|
||
|
config.eager_load = false
|
||
|
config.enable_reloading = true
|
||
|
# Configure public file server for tests with Cache-Control for performance.
|
||
|
config.public_file_server.enabled = true
|
||
|
config.public_file_server.headers = {
|
||
| lib/redmine/plugin_loader.rb | ||
|---|---|---|
|
# Add the plugin directories to rails autoload paths
|
||
|
engine_cfg = Rails::Engine::Configuration.new(directory.to_s)
|
||
|
engine_cfg.paths.add 'lib', eager_load: true
|
||
|
engine_cfg.eager_load_paths.each do |dir|
|
||
|
engine_cfg.paths.eager_load.each do |dir|
|
||
|
Rails.autoloaders.main.push_dir dir
|
||
|
Rails.application.config.watchable_dirs[dir] = [:rb]
|
||
|
end
|
||
| test/fixtures/plugins/foo_plugin/app/models/foo.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
class Foo < ActiveRecord::Base
|
||
|
end
|
||
| test/unit/lib/redmine/plugin_loader_test.rb | ||
|---|---|---|
|
@klass.directory = Rails.root.join('test/fixtures/plugins')
|
||
|
@klass.public_directory = Rails.root.join('tmp/public/plugin_assets')
|
||
|
@klass.load
|
||
|
Rails.autoloaders.main.reload
|
||
|
end
|
||
|
def teardown
|
||
| ... | ... | |
|
assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
|
||
|
end
|
||
|
def test_autoload
|
||
|
assert_equal true, Object.const_defined?(:Foo)
|
||
|
end
|
||
|
def clear_public
|
||
|
FileUtils.rm_rf 'tmp/public'
|
||
|
end
|
||