-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CPDLP-3484] User migrator find or initialise logic to deal with orphaned ecf user, but return error for all the other scenarios #1705
base: main
Are you sure you want to change the base?
Conversation
Review app deployed to https://npq-registration-review-1705-web.test.teacherservices.cloud/ |
0ca8e00
to
fc72bf2
Compare
fdc3066
to
4d4e858
Compare
4d4e858
to
53d78dc
Compare
5df35b0
to
7be492d
Compare
…aned ecf user, but return error for all the other scenarios
…f_user and one for non orphaned ecf_user
7be492d
to
1086f53
Compare
Quality Gate passedIssues Measures |
raise ActiveRecord::RecordInvalid, ecf_user | ||
end | ||
|
||
ecf_user.errors.add(:base, "End of find_or_initialize_user logic, something weird happened") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we cover this with a test?
end | ||
|
||
context "when linked ecf_user is not an orphan" do | ||
let(:failure_manager) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mock this already in the shared context, so you can test failures similar to this:
@@ -54,6 +54,72 @@ def call | |||
|
|||
private | |||
|
|||
def find_or_initialize_user(ecf_user) | |||
# Find Users with `ecf_user.id` | |||
users_with_ecf_id = ::User.where(ecf_id: ecf_user.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of loading the whole user model into memory here and in the queries below can we just pluck the id
attributes and compare on that? has this been ran on the migration env yet?
@@ -54,6 +54,72 @@ def call | |||
|
|||
private | |||
|
|||
def find_or_initialize_user(ecf_user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a monster function; can we extract several methods to make it easier to follow?
Context
Ticket: https://dfedigital.atlassian.net.mcas.ms/browse/CPDLP-3484
Changes proposed in this pull request
find_or_initialize_user(ecf_user)
method:ecf_user.id
andecf_user.get_an_identity_id
to find users on NPQecf_user.id
, return userecf_user.get_an_identity_id
return a user, look into ECF with theecf_id
ecf_id
ecf_id