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 17, 2024
1 parent a7f485e commit 1086f53
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/services/migration/migrators/user_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
require "rails_helper"

class TmpFailureManager
def initialize
@failures = {}
end

def failures(user)
@failures[user]
end

def record_failure(user, msg)
@failures[user] = msg
end
end

RSpec.describe Migration::Migrators::User do
it_behaves_like "a migrator", :user, [] do
def create_ecf_resource
Expand Down Expand Up @@ -177,12 +191,17 @@ def setup_failure_state
end

context "when linked ecf_user is not an orphan" do
let(:failure_manager) do
TmpFailureManager.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 1086f53

Please sign in to comment.