Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/global_id/identification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Identification
extend ActiveSupport::Concern

def to_global_id(options = {})
@global_id ||= GlobalID.create(self, options)
GlobalID.create(self, options)
end
alias to_gid to_global_id

Expand Down
8 changes: 8 additions & 0 deletions test/cases/global_identification_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ class GlobalIdentificationTest < ActiveSupport::TestCase
assert_equal SignedGlobalID.create(@model, some: 'param'), @model.to_signed_global_id(some: 'param')
assert_equal SignedGlobalID.create(@model, some: 'param'), @model.to_sgid(some: 'param')
end

test 'dup should clear memoized to_global_id' do
global_id = @model.to_global_id
dup_model = @model.dup
dup_model.id = @model.id + 1
dup_global_id = dup_model.to_global_id
assert_not_equal global_id, dup_global_id
end
end