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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New columns to sp_return_logs #10510

Merged
merged 8 commits into from
Apr 29, 2024
Merged

Conversation

samathad2023
Copy link
Contributor

馃帿 Ticket

Link to the relevant ticket:
LG-13011

馃洜 Summary of changes

Three new columns been added to sp_return_logs for billing report

馃摐 Testing Plan

Provide a checklist of steps to confirm the changes.

  • Spec file updates to create sp_return_logs with new columns
  • Validate the columns
  • Validate the values with profile

Comment on lines 25 to 28
create(
:profile, :active, :verified, user: current_user,
initiating_service_provider: current_sp
)
Copy link
Contributor

Choose a reason for hiding this comment

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

personal style, I would line up all the args

Suggested change
create(
:profile, :active, :verified, user: current_user,
initiating_service_provider: current_sp
)
create(
:profile,
:active,
:verified,
user: current_user,
initiating_service_provider: current_sp,
)

Comment on lines 30 to 31
# Do session_started_at and profile_verified_at need to be different, is there some relationship
# to be account for in tests?
Copy link
Contributor

Choose a reason for hiding this comment

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

profile_verified_at is when the user finished IDV.
session_started_at is for the current start of this particular session, which may have no IDV

Comment on lines 25 to 27
profile_id: current_user&.active_profile&.id,
profile_verified_at: current_user&.active_profile&.verified_at,
profile_requested_issuer: current_user&.active_profile&.initiating_service_provider,
Copy link
Contributor

Choose a reason for hiding this comment

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

First, current_user should always be present, so there should be no need for the & directly after it.

Second, we are not always returning profile attributes to partners, maybe we could only check for active_profile if ial > 1 ?

Suggested change
profile_id: current_user&.active_profile&.id,
profile_verified_at: current_user&.active_profile&.verified_at,
profile_requested_issuer: current_user&.active_profile&.initiating_service_provider,
profile_id: current_user.active_profile&.id,
profile_verified_at: current_user.active_profile&.verified_at,
profile_requested_issuer: current_user.active_profile&.initiating_service_provider,

changelog: Internal, Reporting,add new columns to spreturnlogs
@samathad2023 samathad2023 marked this pull request as ready for review April 26, 2024 16:58
Comment on lines 36 to 39
user_session[session_has_been_billed_flag_key] == true
user_session[session_has_been_billed_flag_key]
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we change this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes needed on this.Reverting this change.

it 'does not fail if SpReturnLog row already exists' do
let(:ial_context) { IalContext.new(ial: 2, service_provider: current_sp) }
it 'does not fail if SpReturnLog row already exists and ial 2' do
# binding.pry
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this

Suggested change
# binding.pry

Comment on lines 58 to 78
SpReturnLog.create(
request_id: request_id,
user_id: current_user.id,
billable: true,
ial: ial_context.ial,
issuer: current_sp.issuer,
requested_at: session_started_at,
returned_at: Time.zone.now,
profile_id: active_profile.id,
profile_verified_at: active_profile.verified_at,
profile_requested_issuer: active_profile.initiating_service_provider.issuer,
)

expect do
instance.track_billing_events
end.to_not(change { SpReturnLog.count }.from(1))
sp_return_log = SpReturnLog.last
expect(sp_return_log.profile_id).to eq active_profile.id
expect(sp_return_log.profile_verified_at).to eq active_profile.verified_at
expect(sp_return_log.profile_requested_issuer).
to eq active_profile.initiating_service_provider.issuer
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. let's add a spec that shows the new attributes (profile_id, profile_verified_at, profile_requested_issuer) being added? this spec seems to only show that they do not change right?

  2. let's save the assignment to make it clearer we're referencing the same row

Suggested change
SpReturnLog.create(
request_id: request_id,
user_id: current_user.id,
billable: true,
ial: ial_context.ial,
issuer: current_sp.issuer,
requested_at: session_started_at,
returned_at: Time.zone.now,
profile_id: active_profile.id,
profile_verified_at: active_profile.verified_at,
profile_requested_issuer: active_profile.initiating_service_provider.issuer,
)
expect do
instance.track_billing_events
end.to_not(change { SpReturnLog.count }.from(1))
sp_return_log = SpReturnLog.last
expect(sp_return_log.profile_id).to eq active_profile.id
expect(sp_return_log.profile_verified_at).to eq active_profile.verified_at
expect(sp_return_log.profile_requested_issuer).
to eq active_profile.initiating_service_provider.issuer
sp_return_log = SpReturnLog.create(
request_id: request_id,
user_id: current_user.id,
billable: true,
ial: ial_context.ial,
issuer: current_sp.issuer,
requested_at: session_started_at,
returned_at: Time.zone.now,
profile_id: active_profile.id,
profile_verified_at: active_profile.verified_at,
profile_requested_issuer: active_profile.initiating_service_provider.issuer,
)
expect do
instance.track_billing_events
end.to_not(change { SpReturnLog.count }.from(1))
sp_return_log.reload
expect(sp_return_log.profile_id).to eq active_profile.id
expect(sp_return_log.profile_verified_at).to eq active_profile.verified_at
expect(sp_return_log.profile_requested_issuer).
to eq active_profile.initiating_service_provider.issuer

Comment on lines 24 to 30
let(:active_profile) do
create(
:profile,
:active,
:verified,
user: current_user,
initiating_service_provider: current_sp,
Copy link
Contributor

Choose a reason for hiding this comment

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

let's link this to a different service provider (this helps us make sure if we ever added a bug that mixed up SPs, that we'd still catch it

Suggested change
let(:active_profile) do
create(
:profile,
:active,
:verified,
user: current_user,
initiating_service_provider: current_sp,
let(:profile_sp) { create(:service_provider) }
let(:active_profile) do
create(
:profile,
:active,
:verified,
user: current_user,
initiating_service_provider: profile_sp,

samathad2023 and others added 2 commits April 26, 2024 10:50
Comment on lines 61 to 63
expect(sp_return_log.respond_to?(:profile_id)).to be true
expect(sp_return_log.respond_to?(:profile_verified_at)).to be true
expect(sp_return_log.respond_to?(:profile_requested_issuer)).to be true
Copy link
Contributor

Choose a reason for hiding this comment

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

these assertions are basically checking if the migrations ran, I think we should check the values inside the columns to make sure they're what we expect.

For context, these values are what we're going to generate billing reports later on from, so we want to make sure they are correct

These are the assertions from later in the file

Suggested change
expect(sp_return_log.respond_to?(:profile_id)).to be true
expect(sp_return_log.respond_to?(:profile_verified_at)).to be true
expect(sp_return_log.respond_to?(:profile_requested_issuer)).to be true
expect(sp_return_log.profile_id).to eq active_profile.profile_id
expect(sp_return_log.profile_verified_at).to eq active_profile.verified_at
expect(sp_return_log.profile_requested_issuer).
to eq active_profile.profile_requested_issuer

@samathad2023 samathad2023 merged commit 48d62ed into main Apr 29, 2024
2 checks passed
@samathad2023 samathad2023 deleted the cnattrass-lg-13011-sp-return-logs branch April 29, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants