Skip to content

Commit 4ec9833

Browse files
authored
Merge pull request #165 from rails/rm-json-serializer
Make tests pass in Rails 7.1
2 parents 2fab171 + d371dd1 commit 4ec9833

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

lib/global_id/signed_global_id.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def verify_with_legacy_self_validated_metadata(sgid, options)
4242

4343
raise_if_expired(metadata['expires_at'])
4444

45-
metadata['gid'] if pick_purpose(options) == metadata['purpose']
45+
metadata['gid'] if pick_purpose(options)&.to_s == metadata['purpose']&.to_s
4646
rescue ActiveSupport::MessageVerifier::InvalidSignature, ExpiredMessage
4747
nil
4848
end

lib/global_id/verifier.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
class GlobalID
44
class Verifier < ActiveSupport::MessageVerifier
55
private
6-
def encode(data)
6+
def encode(data, **)
77
::Base64.urlsafe_encode64(data)
88
end
99

10-
def decode(data)
10+
def decode(data, **)
1111
::Base64.urlsafe_decode64(data)
1212
end
1313
end

test/cases/railtie_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def setup
1616
@app.config.eager_load = false
1717
@app.config.logger = Logger.new(nil)
1818
@app.config.secret_key_base = ('x' * 30)
19+
@app.config.active_support.cache_format_version = Rails::VERSION::STRING.to_f
1920
end
2021

2122
test 'GlobalID.app for Blog::Application defaults to blog' do

test/cases/signed_global_id_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class SignedGlobalIDPurposeTest < ActiveSupport::TestCase
7171

7272
test 'parse is backwards compatible with the self validated metadata' do
7373
legacy_sgid = "eyJnaWQiOiJnaWQ6Ly9iY3gvUGVyc29uLzUiLCJwdXJwb3NlIjoibG9naW4iLCJleHBpcmVzX2F0IjpudWxsfQ==--4b9630f3a1fb3d7d6584d95d4fac96433ec2deef"
74-
assert_equal @login_sgid, SignedGlobalID.parse(legacy_sgid, for: 'login')
74+
parsed_sgid = SignedGlobalID.parse(legacy_sgid, for: :login)
75+
assert_equal @login_sgid.uri, parsed_sgid.uri
76+
assert_equal @login_sgid.purpose, parsed_sgid.purpose.to_s
7577
end
7678

7779
test 'equal only with same purpose' do

0 commit comments

Comments
 (0)