This repository is currently being migrated. It's locked while the migration is in progress.
File tree Expand file tree Collapse file tree
app/models/simple_forms_api Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments