This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathva10297_spec.rb
More file actions
148 lines (126 loc) · 5.52 KB
/
va10297_spec.rb
File metadata and controls
148 lines (126 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# frozen_string_literal: true
require 'rails_helper'
require 'lib/saved_claims_spec_helper'
RSpec.describe SavedClaim::EducationBenefits::VA10297 do
let(:instance) { build(:va10297_simple_form) }
it_behaves_like 'saved_claim'
validate_inclusion(:form_id, '22-10297')
describe 'retention_period' do
it 'returns the correct period' do
expect(instance.retention_period).to be_within(1.minute).of(60.days)
end
end
describe '#after_submit' do
let(:user) { create(:user) }
before do
allow(VANotify::EmailJob).to receive(:perform_async)
end
describe 'confirmation email for 10297' do
context 'when the form22_10297_confirmation_email feature flag is disabled' do
it 'does not send a confirmation email' do
allow(Flipper).to receive(:enabled?).with(:form22_10297_confirmation_email).and_return(false)
subject = create(:va10297_simple_form)
subject.after_submit(user)
expect(VANotify::EmailJob).not_to have_received(:perform_async)
end
end
context 'when the form22_10297_confirmation_email feature flag is enabled' do
before do
allow(Flipper).to receive(:enabled?).with(:form22_10297_confirmation_email).and_return(true)
end
context 'when the form10297_confirmation_email_with_silent_failure_processing feature flag is disabled' do
before do
allow(Flipper)
.to receive(:enabled?)
.with(:form10297_confirmation_email_with_silent_failure_processing)
.and_return(false)
end
it 'sends an email without the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number
subject.after_submit(user)
expect(VANotify::EmailJob).to have_received(:perform_async).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
}
)
end
end
context 'when the form10297_confirmation_email_with_silent_failure_processing feature flag is enabled' do
let(:callback_options) do
{
callback_metadata: {
notification_type: 'confirmation',
form_number: '22-10297',
statsd_tags: { service: 'submit-10297-form', function: 'form_10297_failure_confirmation_email_sending' }
}
}
end
before do
allow(Flipper)
.to receive(:enabled?)
.with(:form10297_confirmation_email_with_silent_failure_processing)
.and_return(true)
end
context 'when the va_notify_v2_edu_benefits_confirmation_email feature flag is disabled' do
before do
allow(Flipper)
.to receive(:enabled?)
.with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(false)
end
it 'sends an email via V1 EmailJob with the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number
subject.after_submit(user)
expect(VANotify::EmailJob).to have_received(:perform_async).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
},
Settings.vanotify.services.va_gov.api_key,
callback_options
)
end
end
context 'when the va_notify_v2_edu_benefits_confirmation_email feature flag is enabled' do
before do
allow(Flipper)
.to receive(:enabled?)
.with(:va_notify_v2_edu_benefits_confirmation_email)
.and_return(true)
allow(VANotify::V2::QueueEmailJob).to receive(:enqueue)
end
it 'sends an email via V2 QueueEmailJob with the silent failure callback parameters' do
subject = create(:va10297_simple_form)
confirmation_number = subject.education_benefits_claim.confirmation_number
subject.after_submit(user)
expect(VANotify::V2::QueueEmailJob).to have_received(:enqueue).with(
'test@test.com',
'form10297_confirmation_email_template_id',
{
'first_name' => 'TEST',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'regional_office_address' => "P.O. Box 4616\nBuffalo, NY 14240-4616"
},
'Settings.vanotify.services.va_gov.api_key',
callback_options
)
expect(VANotify::EmailJob).not_to have_received(:perform_async)
end
end
end
end
end
end
end