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 app/services/agency_identity_linker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def find_or_create_agency_identity

def create_agency_identity_for_sp
return unless agency_id
AgencyIdentity.create(
AgencyIdentity.create_or_find_by(
agency_id: agency_id,
user_id: @sp_identity.user_id,
uuid: @sp_identity.uuid,
Expand Down
5 changes: 4 additions & 1 deletion spec/services/agency_identity_linker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

it 'links identities from 2 sps' do
sp1 = create_service_provider_identity(user, 'http://localhost:3000', 'UUID1')
create_service_provider_identity(user, 'urn:gov:gsa:openidconnect:test', 'UUID2')
sp2 = create_service_provider_identity(user, 'urn:gov:gsa:openidconnect:test', 'UUID2')
ai = AgencyIdentityLinker.new(sp1).link_identity
ai2 = AgencyIdentityLinker.new(sp2).link_identity
expect(ai.uuid).to eq('UUID1')
expect(ai2.uuid).to eq('UUID1')

ai = AgencyIdentity.where(user_id: user.id).first
expect(ai.uuid).to eq('UUID1')
end
Expand Down