File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,11 @@ class Railtie < Rails::Railtie # :nodoc:
19
19
default_app_name = app . railtie_name . remove ( '_application' ) . dasherize
20
20
21
21
GlobalID . app = app . config . global_id . app ||= default_app_name
22
- SignedGlobalID . expires_in = app . config . global_id . expires_in ||= default_expires_in
22
+ SignedGlobalID . expires_in = app . config . global_id . fetch ( : expires_in, default_expires_in )
23
23
24
24
config . after_initialize do
25
25
GlobalID . app = app . config . global_id . app ||= default_app_name
26
- SignedGlobalID . expires_in = app . config . global_id . expires_in ||= default_expires_in
26
+ SignedGlobalID . expires_in = app . config . global_id . fetch ( : expires_in, default_expires_in )
27
27
28
28
app . config . global_id . verifier ||= begin
29
29
GlobalID ::Verifier . new ( app . key_generator . generate_key ( 'signed_global_ids' ) )
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ def setup
29
29
assert_equal 'foo' , GlobalID . app
30
30
end
31
31
32
+ test 'SignedGlobalID.expires_in can be explicitly set to nil with config.global_id.expires_in' do
33
+ @app . config . global_id . expires_in = nil
34
+ @app . initialize!
35
+ assert_nil SignedGlobalID . expires_in
36
+ end
37
+
32
38
test 'config.global_id can be used to set configurations after the railtie has been loaded' do
33
39
@app . config . eager_load = true
34
40
@app . config . before_eager_load do
@@ -41,6 +47,17 @@ def setup
41
47
assert_equal 1 . year , SignedGlobalID . expires_in
42
48
end
43
49
50
+ test 'config.global_id can be used to explicitly set SignedGlobalID.expires_in to nil after the railtie has been loaded' do
51
+ @app . config . eager_load = true
52
+ @app . config . before_eager_load do
53
+ @app . config . global_id . expires_in = nil
54
+ end
55
+
56
+ @app . initialize!
57
+ assert_nil SignedGlobalID . expires_in
58
+ end
59
+
60
+
44
61
test 'SignedGlobalID.verifier defaults to Blog::Application.message_verifier(:signed_global_ids) when secret_key_base is present' do
45
62
@app . initialize!
46
63
message = { id : 42 }
You can’t perform that action at this time.
0 commit comments