Skip to content

Commit

Permalink
Ruby 3 KwArgs: Various Raven-related specs (#11931)
Browse files Browse the repository at this point in the history
* Ruby 3 KwArgs: Profile Parser spec

* Ruby 3 KwArgs: BB Client spec

* Ruby 3 KwArgs: PSSG Download spec

* Ruby 3 KwArgs: EVSS::FailedClaimsReport spec

* Ruby 3 KwArgs: ApplicationController spec

* Ruby 3 KwArgs: VaProfile Contact Info Service spec
  • Loading branch information
ericboehs authored Mar 1, 2023
1 parent 6caae70 commit 13151c7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
60 changes: 34 additions & 26 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,28 @@ def append_info_to_payload(payload)
allow_any_instance_of(Rx::Client)
.to receive(:connection).and_raise(Faraday::ConnectionFailed, 'some message')
expect(Raven).to receive(:extra_context).once.with(
request_uuid: nil
{ request_uuid: nil }
)
expect(Raven).to receive(:extra_context).once.with(
va_exception_errors: [{
title: 'Service unavailable',
detail: 'Backend Service Outage',
code: '503',
status: '503'
}]
{
va_exception_errors: [{
title: 'Service unavailable',
detail: 'Backend Service Outage',
code: '503',
status: '503'
}]
}
)
# if current user is nil it means user is not signed in.
expect(Raven).to receive(:tags_context).once.with(
controller_name: 'anonymous',
sign_in_method: 'not-signed-in',
source: 'my_testing'
{
controller_name: 'anonymous',
sign_in_method: 'not-signed-in',
source: 'my_testing'
}
)
expect(Raven).to receive(:tags_context).once.with(
error: 'mhv_session'
{ error: 'mhv_session' }
)
# since user is not signed in this shouldnt get called.
expect(Raven).not_to receive(:user_context)
Expand All @@ -268,30 +272,34 @@ def append_info_to_payload(payload)
allow_any_instance_of(Rx::Client)
.to receive(:connection).and_raise(Faraday::ConnectionFailed, 'some message')
expect(Raven).to receive(:extra_context).once.with(
request_uuid: nil
{ request_uuid: nil }
)
expect(Raven).to receive(:extra_context).once.with(
va_exception_errors: [{
title: 'Service unavailable',
detail: 'Backend Service Outage',
code: '503',
status: '503'
}]
{
va_exception_errors: [{
title: 'Service unavailable',
detail: 'Backend Service Outage',
code: '503',
status: '503'
}]
}
)
# if authn_context is nil on current_user it means idme
expect(Raven).to receive(:tags_context).once.with(controller_name: 'anonymous',
sign_in_method: SignIn::Constants::Auth::IDME,
sign_in_acct_type: nil)
expect(Raven).to receive(:tags_context).once.with(
{ controller_name: 'anonymous', sign_in_method: SignIn::Constants::Auth::IDME, sign_in_acct_type: nil }
)

expect(Raven).to receive(:tags_context).once.with(
error: 'mhv_session'
{ error: 'mhv_session' }
)
# since user IS signed in, this SHOULD get called
expect(Raven).to receive(:user_context).with(
id: user.uuid,
authn_context: user.authn_context,
loa: user.loa,
mhv_icn: user.mhv_icn
{
id: user.uuid,
authn_context: user.authn_context,
loa: user.loa,
mhv_icn: user.mhv_icn
}
)
expect(Raven).to receive(:capture_exception).once.with(
Faraday::ConnectionFailed,
Expand Down
8 changes: 5 additions & 3 deletions spec/jobs/evss/failed_claims_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@
end

expect(Aws::S3::Resource).to receive(:new).once.with(
access_key_id: 'EVSS_S3_AWS_ACCESS_KEY_ID_XYZ',
secret_access_key: 'EVSS_S3_AWS_SECRET_ACCESS_KEY_XYZ',
region: 'evss_s3_region'
{
access_key_id: 'EVSS_S3_AWS_ACCESS_KEY_ID_XYZ',
secret_access_key: 'EVSS_S3_AWS_SECRET_ACCESS_KEY_XYZ',
region: 'evss_s3_region'
}
).and_return(s3)
allow(s3).to receive(:bucket).twice.and_return(bucket)
allow(bucket).to receive(:objects).and_return(objects)
Expand Down
4 changes: 3 additions & 1 deletion spec/jobs/facilities/pssg_download_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@
).to receive(:extract_polygon).with(any_args).and_raise(RGeo::Error::InvalidGeometry)

expect(Raven).to receive(:capture_exception).with(RGeo::Error::InvalidGeometry, level: 'error')
expect(Raven).to receive(:extra_context).with('Band name' => drive_time_data_648A4[0]['attributes']['Name'])
expect(Raven).to receive(:extra_context).with(
{ 'Band name' => drive_time_data_648A4[0]['attributes']['Name'] }
)

subject.perform
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/bb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
it 'logs failed extract statuses', :vcr do
VCR.use_cassette('bb_client/gets_a_list_of_extract_statuses') do
msg = 'Final health record refresh contained one or more error statuses'
expect(Raven).to receive(:extra_context).with(refresh_failures: %w[Appointments ImagingStudy])
expect(Raven).to receive(:extra_context).with({ refresh_failures: %w[Appointments ImagingStudy] })
expect(Raven).to receive(:capture_message).with(msg, level: 'warning')

client.get_extract_status
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/mpi/responses/profile_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@
it 'logs warning about inactive IDs' do
msg1 = 'Inactive MHV correlation IDs present'
msg2 = 'Returning inactive MHV correlation ID as first identifier'
expect(Raven).to receive(:extra_context).with(ids: %w[12345678901 12345678902]).twice
expect(Raven).to receive(:extra_context).with({ ids: %w[12345678901 12345678902] }).twice
expect(Raven).to receive(:capture_message).with(msg1, level: 'info')
expect(Raven).to receive(:capture_message).with(msg2, level: 'warning')
parser.parse
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/va_profile/contact_information/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@
expect(VANotifyEmailJob).to receive(:perform_async).with(
'email@email.com',
described_class::CONTACT_INFO_CHANGE_TEMPLATE,
'contact_info' => 'Email address'
{ 'contact_info' => 'Email address' }
)
expect(VANotifyEmailJob).to receive(:perform_async).with(
'person43@example.com',
described_class::CONTACT_INFO_CHANGE_TEMPLATE,
'contact_info' => 'Email address'
{ 'contact_info' => 'Email address' }
)

subject.get_email_transaction_status(transaction_id)
Expand Down Expand Up @@ -516,7 +516,7 @@
expect(VANotifyEmailJob).to receive(:perform_async).with(
user.va_profile_email,
described_class::CONTACT_INFO_CHANGE_TEMPLATE,
'contact_info' => 'Email address'
{ 'contact_info' => 'Email address' }
)

subject.send(:send_contact_change_notification, transaction_status, :email)
Expand Down

0 comments on commit 13151c7

Please sign in to comment.