Project

General

Profile

Feature #36320 » 0001-Fix-autoloading-plugin-classes.patch

Takashi Kato, 2023-11-28 13:12

View differences:

config/environments/test.rb
18 18
  # preloads Rails for running tests, you may have to set it to true.
19 19
  config.eager_load = false
20 20

  
21
  config.enable_reloading = true
22

  
21 23
  # Configure public file server for tests with Cache-Control for performance.
22 24
  config.public_file_server.enabled = true
23 25
  config.public_file_server.headers = {
lib/redmine/plugin_loader.rb
126 126
        # Add the plugin directories to rails autoload paths
127 127
        engine_cfg = Rails::Engine::Configuration.new(directory.to_s)
128 128
        engine_cfg.paths.add 'lib', eager_load: true
129
        engine_cfg.eager_load_paths.each do |dir|
129
        engine_cfg.paths.eager_load.each do |dir|
130 130
          Rails.autoloaders.main.push_dir dir
131 131
          Rails.application.config.watchable_dirs[dir] = [:rb]
132 132
        end
test/fixtures/plugins/foo_plugin/app/models/foo.rb
1
# frozen_string_literal: true
2

  
3
class Foo < ActiveRecord::Base
4
end
test/unit/lib/redmine/plugin_loader_test.rb
27 27
    @klass.directory = Rails.root.join('test/fixtures/plugins')
28 28
    @klass.public_directory = Rails.root.join('tmp/public/plugin_assets')
29 29
    @klass.load
30
    Rails.autoloaders.main.reload
30 31
  end
31 32

  
32 33
  def teardown
......
55 56
    assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
56 57
  end
57 58

  
59
  def test_autoload
60
    assert_equal true, Object.const_defined?(:Foo)
61
  end
62

  
58 63
  def clear_public
59 64
    FileUtils.rm_rf 'tmp/public'
60 65
  end
(7-7/8)