Skip to content
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

[DPC-4299] - Update AO job so sanctions don't affect org API access #2280

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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: 0 additions & 2 deletions dpc-portal/app/jobs/verify_ao_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def handle_error(link, message)

def update_ao_sanctions(link, message)
link.user.update!(entity_error_attributes(message))
link.provider_organization.update!(entity_error_attributes(message))
unverify_all_links_and_orgs(link.user, message)
end

Expand All @@ -69,7 +68,6 @@ def links_to_check
def unverify_all_links_and_orgs(user, message)
AoOrgLink.where(user:, verification_status: true).each do |link|
link.update!(link_error_attributes(message))
link.provider_organization.update!(entity_error_attributes(message))
logger.info(["#{self.class.name} Check Fail",
{ actionContext: LoggingConstants::ActionContext::BatchVerificationCheck,
actionType: LoggingConstants::ActionType::FailCpiApiGwCheck,
Expand Down
15 changes: 6 additions & 9 deletions dpc-portal/spec/jobs/verify_ao_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def expect_audits(link, also: [])
links << create(:ao_org_link, last_checked_at: (n + 4).days.ago, user:, provider_organization:)
end
end
it "should update user and all user's orgs and links" do
# @@@
it 'should update user, but not impact ProviderOrganization.verification_status' do
expect(AoOrgLink.where(last_checked_at: ..6.days.ago).count).to eq 1
VerifyAoJob.perform_now
links.each do |link|
Expand All @@ -188,8 +189,7 @@ def expect_audits(link, also: [])
expect(link.verification_reason).to eq 'ao_med_sanctions'
expect(link.user.verification_status).to eq 'rejected'
expect(link.user.verification_reason).to eq 'ao_med_sanctions'
expect(link.provider_organization.verification_status).to eq 'rejected'
expect(link.provider_organization.verification_reason).to eq 'ao_med_sanctions'
expect(link.provider_organization.verification_status).to eq 'approved'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(link.provider_organization.verification_status).to eq 'approved'
expect(link.provider_organization.verification_status).to eq 'approved'
expect(link.provider_organization.verification_reason).to be nil

end
end
it 'should log user check failed' do
Expand All @@ -198,11 +198,8 @@ def expect_audits(link, also: [])
expect_log_for(link, 'ao_med_sanctions')
end
VerifyAoJob.perform_now
links.each do |link|
expect_audits(link, also: %i[user org])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have all the context here, but should this still check the link and user audits, ie just remove org from the also params?

end
end
it 'should not update former org/link' do
it 'neither former nor current org link updated when ao verification status rejected' do
user = create(:user, pac_id: '900666666', verification_status: :approved)
provider_organization = create(:provider_organization, verification_status: :approved)
link = create(:ao_org_link, last_checked_at: 8.days.ago, user:, provider_organization:)
Expand All @@ -216,8 +213,8 @@ def expect_audits(link, also: [])
expect(link.verification_reason).to eq 'ao_med_sanctions'
expect(link.user.verification_status).to eq 'rejected'
expect(link.user.verification_reason).to eq 'ao_med_sanctions'
expect(link.provider_organization.verification_status).to eq 'rejected'
expect(link.provider_organization.verification_reason).to eq 'ao_med_sanctions'
expect(link.provider_organization.verification_status).to eq 'approved'
expect(link.provider_organization.verification_reason).to be nil
expect(link.verification_status).to be false
former_link.reload
expect(former_link.verification_reason).to eq 'user_not_authorized_official'
Expand Down
Loading