Skip to content

Commit

Permalink
Implement simple forms notification_email_address
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrillberg committed Jan 28, 2025
1 parent 23101f0 commit a8d95f1
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ def initialize(data)
def notification_first_name
data.dig('veteran_full_name', 'first')
end

def notification_email_address
data.dig('veteran', 'email')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def notification_first_name
data.dig('full_name', 'first')
end

def notification_email_address
data['email_address']
end

def zip_code_is_us_based
@data.dig('address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ def notification_first_name
end
end

def notification_email_address
if %w[veteran third-party-veteran].include? data['preparer_type']
data['veteran_email_address']
else
data['non_veteran_email_address']
end
end

def zip_code_is_us_based
@data.dig('veteran_mailing_address', 'country') == 'USA' ||
@data.dig('non_veteran_mailing_address', 'country') == 'USA'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def notification_first_name
end
end

def notification_email_address
if data['authorizer_type'] == 'veteran'
data['veteran_email']
elsif data['authorizer_type'] == 'nonVeteran'
data['authorizer_email']
end
end

def zip_code_is_us_based
@data.dig('authorizer_address',
'country') == 'USA' || @data.dig('person_address',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def notification_first_name
end
end

def notification_email_address
if data['preparer_identification'] == 'SURVIVING_DEPENDENT'
data['surviving_dependent_email']
else
data['veteran_email']
end
end

def zip_code_is_us_based
@data.dig('veteran_mailing_address',
'country') == 'USA' || @data.dig('surviving_dependent_mailing_address', 'country') == 'USA'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def notification_first_name
data.dig('preparer_full_name', 'first')
end

def notification_email_address
data['preparer_email']
end

def zip_code_is_us_based
@data.dig('preparer_address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def notification_first_name
end
end

def notification_email_address
if data['claim_ownership'] == 'self' && @data['claimant_type'] == 'veteran'
data['veteran_email']
elsif data['claim_ownership'] == 'self' && @data['claimant_type'] == 'non-veteran'
data['claimant_email']
elsif data['claim_ownership'] == 'third-party'
data['witness_email']
end
end

def zip_code_is_us_based
@data.dig('veteran_mailing_address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def notification_first_name
data.dig('veteran', 'full_name', 'first')
end

def notification_email_address
data.dig('veteran', 'email')
end

def zip_code_is_us_based
@data.dig('veteran', 'address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def notification_first_name
data.dig('preparer_name', 'first')
end

def notification_email_address
data['preparer_email']
end

def zip_code_is_us_based
@data.dig('preparer_address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def notification_first_name
data.dig('veteran', 'full_name', 'first')
end

def notification_email_address
data.dig('veteran', 'email')
end

def zip_code_is_us_based
@data.dig('veteran', 'address', 'country') == 'USA'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def notification_first_name
data.dig('applicant_full_name', 'first')
end

def notification_email_address
data['applicant_email']
end

def veteran_name
first_name = data.dig('veteran_full_name', 'first') || ''
middle_name = data.dig('veteran_full_name', 'middle') || ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def notification_first_name
end
end

def notification_email_address
data.dig('application', 'claimant', 'email')
end

def zip_code_is_us_based
# TODO: Implement this
true
Expand Down
8 changes: 8 additions & 0 deletions modules/simple_forms_api/spec/models/base_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
it 'returns the email address to be used in notifications' do
data = { 'veteran' => { 'email' => '[email protected]' } }

expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
10 changes: 10 additions & 0 deletions modules/simple_forms_api/spec/models/vba_20_10206_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
let(:data) do
{ 'email_address' => '[email protected]' }
end

it 'returns the email address to be used in notifications' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
41 changes: 41 additions & 0 deletions modules/simple_forms_api/spec/models/vba_20_10207_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,45 @@
end
end
end

describe '#notification_email_address' do
context 'preparer is veteran' do
let(:data) do
{
'preparer_type' => 'veteran',
'veteran_email_address' => '[email protected]'
}
end

it 'returns the veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end

context 'preparer is third party veteran' do
let(:data) do
{
'preparer_type' => 'third-party-veteran',
'veteran_email_address' => '[email protected]'
}
end

it 'returns the veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end

context 'preparer is anything else' do
let(:data) do
{
'preparer_type' => 'space-alien',
'non_veteran_email_address' => '[email protected]'
}
end

it 'returns the non-veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
end
28 changes: 28 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_0845_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,32 @@
end
end
end

describe '#notification_email_address' do
context 'preparer is veteran' do
let(:data) do
{
'authorizer_type' => 'veteran',
'veteran_email' => '[email protected]'
}
end

it 'returns the veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end

context 'preparer is nonVeteran' do
let(:data) do
{
'authorizer_type' => 'nonVeteran',
'authorizer_email' => '[email protected]'
}
end

it 'returns the authorizer email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
end
28 changes: 28 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_0966_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,32 @@
end
end
end

describe '#notification_email_address' do
context 'preparer is surviving dependent' do
let(:data) do
{
'preparer_type' => 'SURVIVING_DEPENDENT',
'surviving_dependent_email' => '[email protected]'
}
end

it 'returns the surviving dependent email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end

context 'preparer is anyone else' do
let(:data) do
{
'preparer_type' => 'space-alien',
'veteran_email' => '[email protected]'
}
end

it 'returns the veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
end
10 changes: 10 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_0972_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
let(:data) do
{ 'preparer_email' => '[email protected]' }
end

it 'returns the email address to be used in notifications' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
45 changes: 45 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_10210_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,49 @@
end
end
end

describe '#notification_email_address' do
context "preparer's own claim" do
context 'preparer is veteran' do
let(:data) do
{
'claim_ownership' => 'self',
'claimant_type' => 'veteran',
'veteran_email' => '[email protected]'
}
end

it 'returns the veteran email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end

context 'preparer is not veteran' do
let(:data) do
{
'claim_ownership' => 'self',
'claimant_type' => 'non-veteran',
'claimant_email' => '[email protected]'
}
end

it 'returns the claimant email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end

context 'third party claim' do
let(:data) do
{
'claim_ownership' => 'third-party',
'witness_email' => '[email protected]'
}
end

it 'returns the witness email address' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
end
10 changes: 10 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_4142_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
let(:data) do
{ 'veteran_email' => '[email protected]' }
end

it 'returns the email address to be used in notifications' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
10 changes: 10 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21p_0847_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
let(:data) do
{ 'preparer_email' => '[email protected]' }
end

it 'returns the email address to be used in notifications' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
10 changes: 10 additions & 0 deletions modules/simple_forms_api/spec/models/vba_26_4555_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@
expect(described_class.new(data).notification_first_name).to eq 'Veteran'
end
end

describe '#notification_email_address' do
let(:data) do
{ 'veteran' => { 'email' => '[email protected]' } }
end

it 'returns the email address to be used in notifications' do
expect(described_class.new(data).notification_email_address).to eq '[email protected]'
end
end
end
Loading

0 comments on commit a8d95f1

Please sign in to comment.