Skip to content

Commit cae40f6

Browse files
authored
Add feature flag to begin removal of EDU and C&P email templates #92636 (#21671)
1 parent af31240 commit cae40f6

File tree

8 files changed

+123
-74
lines changed

8 files changed

+123
-74
lines changed

app/mailers/direct_deposit_mailer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class DirectDepositMailer < TransactionalEmailMailer
99
TEMPLATE = 'direct_deposit'
1010

1111
DD_TYPES = {
12-
ch33: 'education',
1312
comp_pen: 'disability compensation or pension'
1413
}.freeze
1514

app/sidekiq/va_notify_dd_email_job.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def perform(email, dd_type = nil)
4242
end
4343

4444
def template_type(dd_type)
45-
return 'direct_deposit_edu' if dd_type&.to_sym == :ch33
46-
return 'direct_deposit_comp_pen' if %i[comp_pen comp_and_pen].include? dd_type&.to_sym
45+
return 'direct_deposit_comp_pen' if use_comp_pen_email_template?(dd_type)
4746

4847
'direct_deposit'
4948
end
@@ -54,4 +53,12 @@ def handle_errors(ex)
5453

5554
raise ex if ex.status_code.between?(500, 599)
5655
end
56+
57+
def use_direct_deposit_email_template?
58+
Flipper.enabled?(:only_use_direct_deposit_email_template)
59+
end
60+
61+
def use_comp_pen_email_template?(dd_type)
62+
%i[comp_pen comp_and_pen].include?(dd_type&.to_sym) && !use_direct_deposit_email_template?
63+
end
5764
end

config/features.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ features:
2929
enable_in_development: true
3030
accredited_representative_portal_search:
3131
actor_type: user
32-
description: Enables the people search of the accredited representative portal
32+
description: Enables the people search of the accredited representative portal
3333
enable_in_development: true
3434
aedp_vadx:
3535
actor_type: user
@@ -2109,3 +2109,6 @@ features:
21092109
forms_10215_10216_release:
21102110
actor_type: user
21112111
description: If enabled, show links to new forms instead of download links on SCO page
2112+
only_use_direct_deposit_email_template:
2113+
description: If enabled, VANotifyDdEmailJob will not use the EDU and/or C&P email templates
2114+

config/settings.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,6 @@ vanotify:
15561556
covid_vaccine_registration: <%= ENV['vanotify__services__va_gov__template_id__covid_vaccine_registration'] %>
15571557
direct_deposit: <%= ENV['vanotify__services__va_gov__template_id__direct_deposit'] %>
15581558
direct_deposit_comp_pen: <%= ENV['vanotify__services__va_gov__template_id__direct_deposit_comp_pen'] %>
1559-
direct_deposit_edu: <%= ENV['vanotify__services__va_gov__template_id__direct_deposit_edu'] %>
15601559
form0994_confirmation_email: <%= ENV['vanotify__services__va_gov__template_id__form0994_confirmation_email'] %>
15611560
form0994_extra_action_confirmation_email: <%= ENV['vanotify__services__va_gov__template_id__form0994_extra_action_confirmation_email'] %>
15621561
form1010ez_reminder_email: <%= ENV['vanotify__services__va_gov__template_id__form1010ez_reminder_email'] %>

config/settings/development.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,6 @@ vanotify:
15771577
covid_vaccine_registration: ~
15781578
direct_deposit: direct_deposit_template_id
15791579
direct_deposit_comp_pen: comp_pen_template_id
1580-
direct_deposit_edu: edu_template_id
15811580
form0994_confirmation_email: form0994_confirmation_email_template_id
15821581
form0994_extra_action_confirmation_email: form0994_extra_action_confirmation_email_template_id
15831582
form1010ez_reminder_email: fake_template_id

config/settings/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,6 @@ vanotify:
15711571
covid_vaccine_registration: ~
15721572
direct_deposit: direct_deposit_template_id
15731573
direct_deposit_comp_pen: comp_pen_template_id
1574-
direct_deposit_edu: edu_template_id
15751574
form0994_confirmation_email: form0994_confirmation_email_template_id
15761575
form0994_extra_action_confirmation_email: form0994_extra_action_confirmation_email_template_id
15771576
form1010ez_reminder_email: fake_template_id

spec/mailers/direct_deposit_mailer_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,5 @@
3030
)
3131
end
3232
end
33-
34-
context 'ch33 email' do
35-
let(:dd_type) { :ch33 }
36-
37-
it 'includes the right text' do
38-
expect(subject.body.raw_source).to include(
39-
"We'll use your updated information to deposit any education benefits you may receive"
40-
)
41-
end
42-
43-
context 'string dd_type' do
44-
let(:dd_type) { 'ch33' }
45-
46-
it 'includes the right text' do
47-
expect(subject.body.raw_source).to include(
48-
"We'll use your updated information to deposit any education benefits you may receive"
49-
)
50-
end
51-
end
52-
end
5333
end
5434
end

spec/sidekiq/va_notify_dd_email_job_spec.rb

Lines changed: 110 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
]
1515

1616
emails.each do |email|
17-
expect(described_class).to receive(:perform_async).with(email, 'ch33')
17+
expect(described_class).to receive(:perform_async).with(email, 'direct_deposit')
1818
end
1919

20-
described_class.send_to_emails(emails, 'ch33')
20+
described_class.send_to_emails(emails, 'direct_deposit')
2121
end
2222
end
2323

@@ -30,50 +30,91 @@
3030
feature: 'direct_deposit'
3131
)
3232

33-
described_class.send_to_emails([], 'ch33')
33+
described_class.send_to_emails([], 'direct_deposit')
3434
end
3535
end
3636
end
3737

3838
describe '#perform' do
3939
let(:notification_client) { double('Notifications::Client') }
4040

41-
context 'with a dd type of ch33' do
42-
it 'sends a confirmation email using the edu template' do
43-
allow(VaNotify::Service).to receive(:new)
44-
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
41+
context 'with a dd_type of comp_pen' do
42+
context 'with Flipper :only_use_direct_deposit_email_template' do
43+
context 'enabled' do
44+
before do
45+
allow(Flipper).to receive(:enabled?)
46+
.with(:only_use_direct_deposit_email_template).and_return(true)
47+
end
4548

46-
expect(notification_client).to receive(:send_email).with(
47-
email_address: email, template_id: 'edu_template_id'
48-
)
49+
it 'sends a confirmation email using the direct_deposit template' do
50+
allow(VaNotify::Service).to receive(:new)
51+
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
4952

50-
described_class.new.perform(email, 'ch33')
51-
end
52-
end
53+
expect(notification_client).to receive(:send_email).with(
54+
email_address: email, template_id: 'direct_deposit_template_id'
55+
)
5356

54-
context 'with a dd type of comp_pen' do
55-
it 'sends a confirmation email using the comp and pen template' do
56-
allow(VaNotify::Service).to receive(:new)
57-
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
57+
described_class.new.perform(email, 'comp_pen')
58+
end
59+
end
5860

59-
expect(notification_client).to receive(:send_email).with(
60-
email_address: email, template_id: 'comp_pen_template_id'
61-
)
61+
context 'disabled' do
62+
before do
63+
allow(Flipper).to receive(:enabled?)
64+
.with(:only_use_direct_deposit_email_template).and_return(false)
65+
end
66+
67+
it 'sends a confirmation email using the comp and pen template' do
68+
allow(VaNotify::Service).to receive(:new)
69+
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
70+
71+
expect(notification_client).to receive(:send_email).with(
72+
email_address: email, template_id: 'comp_pen_template_id'
73+
)
6274

63-
described_class.new.perform(email, 'comp_pen')
75+
described_class.new.perform(email, 'comp_pen')
76+
end
77+
end
6478
end
6579
end
6680

67-
context 'with a dd type of comp_and_pen' do
68-
it 'sends a confirmation email using the comp and pen template' do
69-
allow(VaNotify::Service).to receive(:new)
70-
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
81+
context 'with a dd_type of comp_and_pen' do
82+
context 'with Flipper :only_use_direct_deposit_email_template' do
83+
context 'enabled' do
84+
before do
85+
allow(Flipper).to receive(:enabled?)
86+
.with(:only_use_direct_deposit_email_template).and_return(true)
87+
end
7188

72-
expect(notification_client).to receive(:send_email).with(
73-
email_address: email, template_id: 'comp_pen_template_id'
74-
)
89+
it 'sends a confirmation email using the direct_deposit template' do
90+
allow(VaNotify::Service).to receive(:new)
91+
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
7592

76-
described_class.new.perform(email, 'comp_and_pen')
93+
expect(notification_client).to receive(:send_email).with(
94+
email_address: email, template_id: 'direct_deposit_template_id'
95+
)
96+
97+
described_class.new.perform(email, 'comp_and_pen')
98+
end
99+
end
100+
101+
context 'disabled' do
102+
before do
103+
allow(Flipper).to receive(:enabled?)
104+
.with(:only_use_direct_deposit_email_template).and_return(false)
105+
end
106+
107+
it 'sends a confirmation email using the comp and pen template' do
108+
allow(VaNotify::Service).to receive(:new)
109+
.with(Settings.vanotify.services.va_gov.api_key).and_return(notification_client)
110+
111+
expect(notification_client).to receive(:send_email).with(
112+
email_address: email, template_id: 'comp_pen_template_id'
113+
)
114+
115+
described_class.new.perform(email, 'comp_and_pen')
116+
end
117+
end
77118
end
78119
end
79120

@@ -126,36 +167,58 @@
126167
end
127168
end
128169

129-
describe '#get_template' do
170+
describe '#template_type' do
130171
let(:job) { VANotifyDdEmailJob.new }
131172

132-
context 'when dd_type is nil' do
133-
it 'returns the direct_deposit template' do
134-
expect(job.template_type(nil)).to eq('direct_deposit')
173+
shared_examples 'template type with feature flag' do |dd_type, expected_template|
174+
it "returns the #{expected_template} template when dd_type is #{dd_type}" do
175+
expect(job.template_type(dd_type)).to eq(expected_template)
135176
end
136177
end
137178

138-
context 'when dd_type is unknown' do
139-
it 'returns the direct_deposit template' do
140-
expect(job.template_type('fake')).to eq('direct_deposit')
179+
context 'with Flipper :only_use_direct_deposit_email_template enabled' do
180+
before do
181+
allow(Flipper).to receive(:enabled?)
182+
.with(:only_use_direct_deposit_email_template).and_return(true)
141183
end
142-
end
143184

144-
context 'when dd_type is comp_pen' do
145-
it 'returns the direct_deposit_comp_pen template' do
146-
expect(job.template_type('comp_pen')).to eq('direct_deposit_comp_pen')
185+
context 'when dd_type is nil' do
186+
include_examples 'template type with feature flag', nil, 'direct_deposit'
147187
end
148-
end
149188

150-
context 'when dd_type is comp_and_pen' do
151-
it 'returns the direct_deposit_comp_pen template' do
152-
expect(job.template_type('comp_and_pen')).to eq('direct_deposit_comp_pen')
189+
context 'when dd_type is unknown' do
190+
include_examples 'template type with feature flag', 'fake', 'direct_deposit'
191+
end
192+
193+
context 'when dd_type is comp_pen' do
194+
include_examples 'template type with feature flag', 'comp_pen', 'direct_deposit'
195+
end
196+
197+
context 'when dd_type is comp_and_pen' do
198+
include_examples 'template type with feature flag', 'comp_and_pen', 'direct_deposit'
153199
end
154200
end
155201

156-
context 'when dd_type is edu' do
157-
it 'returns the direct_deposit_edu template' do
158-
expect(job.template_type('ch33')).to eq('direct_deposit_edu')
202+
context 'with Flipper :only_use_direct_deposit_email_template disabled' do
203+
before do
204+
allow(Flipper).to receive(:enabled?)
205+
.with(:only_use_direct_deposit_email_template).and_return(false)
206+
end
207+
208+
context 'when dd_type is nil' do
209+
include_examples 'template type with feature flag', nil, 'direct_deposit'
210+
end
211+
212+
context 'when dd_type is unknown' do
213+
include_examples 'template type with feature flag', 'fake', 'direct_deposit'
214+
end
215+
216+
context 'when dd_type is comp_pen' do
217+
include_examples 'template type with feature flag', 'comp_pen', 'direct_deposit_comp_pen'
218+
end
219+
220+
context 'when dd_type is comp_and_pen' do
221+
include_examples 'template type with feature flag', 'comp_and_pen', 'direct_deposit_comp_pen'
159222
end
160223
end
161224
end

0 commit comments

Comments
 (0)