Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit 874fe1c

Browse files
Change key to match fe4138 (#27501)
* change method to use email function * add tests * update the fixture
1 parent ea06c81 commit 874fe1c

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

modules/simple_forms_api/app/models/simple_forms_api/vba_21_4138.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def notification_first_name
9292
end
9393

9494
def notification_email_address
95-
data['email_address']
95+
veteran_email
9696
end
9797

9898
def zip_code_is_us_based

modules/simple_forms_api/spec/fixtures/form_json/vba_21_4138.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
"last": "Veteran"
77
},
88
"date_of_birth": "1980-01-01",
9-
"email_address": "john.veteran@captainsparkles.net",
9+
"veteran": {
10+
"email": {
11+
"email_address": "john.veteran@captainsparkles.net"
12+
}
13+
},
1014
"id_number": {
1115
"ssn": "321540987",
1216
"va_file_number": "12345678"

modules/simple_forms_api/spec/models/vba_21_4138_spec.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,29 @@
388388
end
389389

390390
describe '#notification_email_address' do
391-
let(:data) { { 'email_address' => 'john@example.com' } }
391+
context 'when the veteran is filing' do
392+
it 'returns email from the nested veteran object' do
393+
data = { 'claimant_type' => 'self', 'veteran' => { 'email' => { 'email_address' => 'veteran@example.com' } } }
394+
expect(described_class.new(data).notification_email_address).to eq('veteran@example.com')
395+
end
396+
397+
it 'returns veteran_email_address when nested veteran email is absent' do
398+
data = { 'claimant_type' => 'self', 'veteran_email_address' => 'veteran@example.com' }
399+
expect(described_class.new(data).notification_email_address).to eq('veteran@example.com')
400+
end
401+
end
392402

393-
it 'returns the email address' do
394-
expect(described_class.new(data).notification_email_address).to eq('john@example.com')
403+
context 'when a non-veteran claimant is filing' do
404+
it 'returns veteran_email_address' do
405+
data = { 'claimant_type' => 'forVeteran', 'veteran_email_address' => 'veteran@example.com' }
406+
expect(described_class.new(data).notification_email_address).to eq('veteran@example.com')
407+
end
408+
end
409+
410+
context 'when no email is present' do
411+
it 'returns nil' do
412+
expect(described_class.new({}).notification_email_address).to be_nil
413+
end
395414
end
396415
end
397416

0 commit comments

Comments
 (0)