Skip to content

Commit

Permalink
[CPDLP-3484] failure_manager will receive multiple errors, one for ec…
Browse files Browse the repository at this point in the history
…f_user and one for non orphaned ecf_user
  • Loading branch information
mooktakim committed Sep 16, 2024
1 parent 53d78dc commit 5df35b0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion spec/services/migration/migrators/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,27 @@ def setup_failure_state
end

context "when linked ecf_user is not an orphan" do
let(:failure_manager) do
Struct.new {
def failures(user)
@failures ||= {}
@failures[user]
end

def record_failure(user, msg)
@failures ||= {}
@failures[user] = msg
end
}.new
end

it "raises error" do
non_orphaned_ecf_user = create(:ecf_migration_user, :npq, id: user.ecf_id)
expect(non_orphaned_ecf_user.npq_applications).to be_present

instance.call
expect(failure_manager).to have_received(:record_failure).with(ecf_user, /User found with ecf_user.get_an_identity_id, but its user.ecf_id linked to another ecf_user that is not an orphan/)
expect(failure_manager.failures(ecf_user)).to eq("Validation failed: User found with ecf_user.get_an_identity_id, but its user.ecf_id linked to another ecf_user that is not an orphan")
expect(failure_manager.failures(non_orphaned_ecf_user)).to eq("Validation failed: Participant identity email from ECF does not match existing user email in NPQ")
end
end
end
Expand Down

0 comments on commit 5df35b0

Please sign in to comment.