Skip to content

Commit

Permalink
VaNotify - Re-enable 1990 confirmation emails to authenticated users (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanbwright authored Jun 8, 2023
1 parent fb7c24f commit ed97e30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
8 changes: 6 additions & 2 deletions app/models/saved_claim/education_benefits/va_1990.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ class SavedClaim::EducationBenefits::VA1990 < SavedClaim::EducationBenefits
def after_submit(user)
return unless Flipper.enabled?(:form1990_confirmation_email)

# only sending to unauthenticated users at this time
return if user.present?
if Flipper.enabled?(:form1990_auth_confirmation_email)
# allow for phased rollout of authenticated users
elsif user.present?
# skip sending to authenticated users
return
end

parsed_form_data ||= JSON.parse(form)
email = parsed_form_data['email']
Expand Down
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ features:
actor_type: user
description: Enables form 1990 email submission confirmation (VaNotify)
enable_in_development: true
form1990_auth_confirmation_email:
actor_type: user
description: Enables form 1990 email submission confirmation for authenticated users (VaNotify)
enable_in_development: true
form1995_confirmation_email:
actor_type: user
description: Enables form 1995 email submission confirmation (VaNotify)
Expand Down
27 changes: 19 additions & 8 deletions spec/models/saved_claim/education_benefits/va1990_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,34 @@
describe '#after_submit' do
let(:user) { create(:user) }

describe 'confirmation email for the 1990' do
it 'is skipped when user is present' do
allow(VANotify::EmailJob).to receive(:perform_async)
it 'is skipped when user is present and feature flag is turned off' do
Flipper.disable(:form1990_auth_confirmation_email)
allow(VANotify::EmailJob).to receive(:perform_async)

subject = create(:va1990_chapter33)
subject.after_submit(user)
subject = create(:va1990_chapter33)
subject.after_submit(user)

expect(VANotify::EmailJob).not_to have_received(:perform_async)
end
expect(VANotify::EmailJob).not_to have_received(:perform_async)
Flipper.enable(:form1990_auth_confirmation_email)
end

it 'is enabled when user is present and feature flag is turned on' do
allow(VANotify::EmailJob).to receive(:perform_async)

subject = create(:va1990_chapter33)
subject.after_submit(user)

expect(VANotify::EmailJob).to have_received(:perform_async)
end

describe 'confirmation email for the 1990' do
it 'chapter 33' do
allow(VANotify::EmailJob).to receive(:perform_async)

subject = create(:va1990_chapter33)
confirmation_number = subject.education_benefits_claim.confirmation_number

subject.after_submit(nil)
subject.after_submit(user)

expect(VANotify::EmailJob).to have_received(:perform_async).with(
'email@example.com',
Expand Down

0 comments on commit ed97e30

Please sign in to comment.