|
14 | 14 | ] |
15 | 15 |
|
16 | 16 | 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') |
18 | 18 | end |
19 | 19 |
|
20 | | - described_class.send_to_emails(emails, 'ch33') |
| 20 | + described_class.send_to_emails(emails, 'direct_deposit') |
21 | 21 | end |
22 | 22 | end |
23 | 23 |
|
|
30 | 30 | feature: 'direct_deposit' |
31 | 31 | ) |
32 | 32 |
|
33 | | - described_class.send_to_emails([], 'ch33') |
| 33 | + described_class.send_to_emails([], 'direct_deposit') |
34 | 34 | end |
35 | 35 | end |
36 | 36 | end |
37 | 37 |
|
38 | 38 | describe '#perform' do |
39 | 39 | let(:notification_client) { double('Notifications::Client') } |
40 | 40 |
|
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 |
45 | 48 |
|
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) |
49 | 52 |
|
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 | + ) |
53 | 56 |
|
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 |
58 | 60 |
|
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 | + ) |
62 | 74 |
|
63 | | - described_class.new.perform(email, 'comp_pen') |
| 75 | + described_class.new.perform(email, 'comp_pen') |
| 76 | + end |
| 77 | + end |
64 | 78 | end |
65 | 79 | end |
66 | 80 |
|
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 |
71 | 88 |
|
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) |
75 | 92 |
|
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 |
77 | 118 | end |
78 | 119 | end |
79 | 120 |
|
|
126 | 167 | end |
127 | 168 | end |
128 | 169 |
|
129 | | - describe '#get_template' do |
| 170 | + describe '#template_type' do |
130 | 171 | let(:job) { VANotifyDdEmailJob.new } |
131 | 172 |
|
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) |
135 | 176 | end |
136 | 177 | end |
137 | 178 |
|
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) |
141 | 183 | end |
142 | | - end |
143 | 184 |
|
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' |
147 | 187 | end |
148 | | - end |
149 | 188 |
|
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' |
153 | 199 | end |
154 | 200 | end |
155 | 201 |
|
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' |
159 | 222 | end |
160 | 223 | end |
161 | 224 | end |
|
0 commit comments