File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class Railtie < Rails::Railtie # :nodoc:
15
15
end
16
16
17
17
initializer "active_job.logger" do
18
- ActiveSupport . on_load ( :active_job ) { self . logger = ::Rails . logger }
18
+ ActiveSupport . on_load ( :active_job ) { self . logger || = ::Rails . logger }
19
19
end
20
20
21
21
initializer "active_job.custom_serializers" do |app |
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "helper"
4
+ require "active_support/testing/isolation"
5
+
6
+ class RailtieTest < ActiveSupport ::TestCase
7
+ include ActiveSupport ::Testing ::Isolation
8
+
9
+ setup do
10
+ require "rails"
11
+
12
+ rails_logger = Logger . new ( nil )
13
+
14
+ @app ||= Class . new ( ::Rails ::Application ) do
15
+ def self . name ; "AJRailtieTestApp" ; end
16
+
17
+ config . eager_load = false
18
+ config . logger = rails_logger
19
+ config . active_support . cache_format_version = 7.1
20
+ end
21
+ end
22
+
23
+ test "active_job.logger initializer does not overwrite the supplied logger" do
24
+ custom_logger = Logger . new ( nil )
25
+
26
+ @app . config . before_initialize do |app |
27
+ ActiveSupport . on_load ( :active_job ) do
28
+ self . logger = custom_logger
29
+ end
30
+ end
31
+
32
+ require "active_job/railtie"
33
+ @app . initialize!
34
+
35
+ assert_same ActiveJob ::Base . logger , custom_logger
36
+ end
37
+ end
You can’t perform that action at this time.
0 commit comments