File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,16 @@ class Railtie < Rails::Railtie # :nodoc:
18
18
default_expires_in = 1 . month
19
19
default_app_name = app . railtie_name . remove ( '_application' ) . dasherize
20
20
21
+ app . config . global_id . expires_in = app . config . global_id . fetch ( :expires_in , default_expires_in )
22
+
21
23
GlobalID . app = app . config . global_id . app ||= default_app_name
22
- SignedGlobalID . expires_in = app . config . global_id . expires_in ||= default_expires_in
24
+ SignedGlobalID . expires_in = app . config . global_id . expires_in
23
25
24
26
config . after_initialize do
27
+ app . config . global_id . expires_in = app . config . global_id . fetch ( :expires_in , default_expires_in )
28
+
25
29
GlobalID . app = app . config . global_id . app ||= default_app_name
26
- SignedGlobalID . expires_in = app . config . global_id . expires_in ||= default_expires_in
30
+ SignedGlobalID . expires_in = app . config . global_id . expires_in
27
31
28
32
app . config . global_id . verifier ||= begin
29
33
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