File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def expired?
4848
4949 sig { returns ( T ::Boolean ) }
5050 def refresh_token_expired?
51- @refresh_token_expires ? @refresh_token_expires < Time . now : false
51+ @refresh_token_expires ? @refresh_token_expires < Time . now + 60 : false
5252 end
5353
5454 sig do
Original file line number Diff line number Diff line change @@ -55,13 +55,13 @@ def test_expired_with_passed_expiry_date
5555 def test_refresh_token_expired_with_no_expiry_date
5656 session = ShopifyAPI ::Auth ::Session . new ( shop : "test-shop" , refresh_token_expires : nil )
5757
58- assert_equal ( false , session . refresh_token_expired? )
58+ refute ( session . refresh_token_expired? )
5959 end
6060
6161 def test_refresh_token_expired_with_future_expiry_date
6262 session = ShopifyAPI ::Auth ::Session . new ( shop : "test-shop" , refresh_token_expires : Time . now + 1 * 60 * 60 )
6363
64- assert_equal ( false , session . refresh_token_expired? )
64+ refute ( session . refresh_token_expired? )
6565 end
6666
6767 def test_refresh_token_expired_with_passed_expiry_date
@@ -70,6 +70,18 @@ def test_refresh_token_expired_with_passed_expiry_date
7070 assert ( session . refresh_token_expired? )
7171 end
7272
73+ def test_refresh_token_expiring_within_buffer
74+ session = ShopifyAPI ::Auth ::Session . new ( shop : "test-shop" , refresh_token_expires : Time . now + 59 )
75+
76+ assert ( session . refresh_token_expired? )
77+ end
78+
79+ def test_refresh_token_expiring_immediately_before_buffer
80+ session = ShopifyAPI ::Auth ::Session . new ( shop : "test-shop" , refresh_token_expires : Time . now + 61 )
81+
82+ refute ( session . refresh_token_expired? )
83+ end
84+
7385 def test_temp
7486 session = ShopifyAPI ::Auth ::Session . new ( shop : "test-shop1" , access_token : "token1" )
7587
Original file line number Diff line number Diff line change @@ -88,7 +88,11 @@ def modify_context(
8888 response_as_struct : response_as_struct || ShopifyAPI ::Context . response_as_struct ,
8989 api_host : api_host || ShopifyAPI ::Context . api_host ,
9090 expiring_offline_access_tokens :
91- expiring_offline_access_tokens || ShopifyAPI ::Context . expiring_offline_access_tokens ,
91+ if !expiring_offline_access_tokens . nil?
92+ expiring_offline_access_tokens
93+ else
94+ ShopifyAPI ::Context . expiring_offline_access_tokens
95+ end ,
9296 )
9397 end
9498 end
You can’t perform that action at this time.
0 commit comments