Skip to content

Commit

Permalink
Update callback default (#19308)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanbwright authored Nov 7, 2024
1 parent 577dfbd commit f9893cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/va_notify/lib/va_notify/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Service < Common::Client::Base
def initialize(api_key, callback_options = {})
overwrite_client_networking
@notify_client ||= Notifications::Client.new(api_key, client_url)
@callback_options = callback_options
@callback_options = callback_options || {}
rescue => e
handle_error(e)
end
Expand Down
15 changes: 15 additions & 0 deletions modules/va_notify/spec/lib/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@
end
end

it 'without nil passed in as callback data' do
subject = VaNotify::Service.new(test_api_key, nil)

VCR.use_cassette('va_notify/success_email') do
allow(Flipper).to receive(:enabled?).with(:va_notify_notification_creation).and_return(true)

subject.send_email(send_email_parameters)
expect(VANotify::Notification.count).to eq(1)
notification = VANotify::Notification.first
expect(notification.source_location).to include('modules/va_notify/spec/lib/service_spec.rb')
expect(notification.callback).to eq(nil)
expect(notification.metadata).to eq(nil)
end
end

it 'with callback data' do
VCR.use_cassette('va_notify/success_email') do
subject = described_class.new(test_api_key, { callback: 'TestCallback', metadata: 'optional_metadata' })
Expand Down

0 comments on commit f9893cf

Please sign in to comment.