diff --git a/app/models/saved_claim/education_benefits/va_1990e.rb b/app/models/saved_claim/education_benefits/va_1990e.rb index d6915284092..f26f1e3856c 100644 --- a/app/models/saved_claim/education_benefits/va_1990e.rb +++ b/app/models/saved_claim/education_benefits/va_1990e.rb @@ -6,8 +6,12 @@ class SavedClaim::EducationBenefits::VA1990e < SavedClaim::EducationBenefits def after_submit(user) return unless Flipper.enabled?(:form1990e_confirmation_email) - # only sending to unauthenticated users at this time - return if user.present? + if Flipper.enabled?(:form1990e_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'] diff --git a/config/features.yml b/config/features.yml index 580107dc80b..34bcb84437c 100644 --- a/config/features.yml +++ b/config/features.yml @@ -370,6 +370,10 @@ features: actor_type: user description: Enables form 1990 email submission confirmation for authenticated users (VaNotify) enable_in_development: true + form1990e_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) diff --git a/spec/models/saved_claim/education_benefits/va1990e_spec.rb b/spec/models/saved_claim/education_benefits/va1990e_spec.rb index f45113e98a2..4f1bd0a5e28 100644 --- a/spec/models/saved_claim/education_benefits/va1990e_spec.rb +++ b/spec/models/saved_claim/education_benefits/va1990e_spec.rb @@ -14,13 +14,24 @@ let(:user) { create(:user) } describe 'confirmation email for the 1990e' do - it 'is skipped when user is present' do + it 'is skipped when user is present and feature flag is turned off' do + Flipper.disable(:form1990e_auth_confirmation_email) allow(VANotify::EmailJob).to receive(:perform_async) subject = create(:va1990e_with_email) subject.after_submit(user) expect(VANotify::EmailJob).not_to have_received(:perform_async) + Flipper.enable(:form1990e_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(:va1990e_with_email) + subject.after_submit(user) + + expect(VANotify::EmailJob).to have_received(:perform_async) end it 'sends if no user is present' do