Skip to content

Commit

Permalink
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
Browse files Browse the repository at this point in the history
…ocalBGS
  • Loading branch information
mchristiansonVA authored Jan 7, 2025
2 parents f2ef47c + 13c0644 commit a8d9931
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ def desired_stamps

def metadata
{
'veteranFirstName' => @data.dig('full_name', 'first'),
'veteranLastName' => @data.dig('full_name', 'last'),
'fileNumber' => @data['va_file_number'].presence || @data['ssn'],
'zipCode' => @data.dig('address', 'postal_code'),
'veteranFirstName' => data.dig('full_name', 'first'),
'veteranLastName' => data.dig('full_name', 'last'),
'fileNumber' => data['va_file_number'].presence || data['ssn'],
'zipCode' => data.dig('address', 'postal_code'),
'source' => 'VA Platform Digital Forms',
'docType' => @data['form_number'],
'docType' => data['form_number'],
'businessLine' => 'CMP'
}
end

def submission_date_stamps(_timestamp)
[]
end

def zip_code_is_us_based
data.dig('address', 'country') == 'USA'
end
end
end
45 changes: 2 additions & 43 deletions modules/simple_forms_api/spec/models/vba_20_10207_spec.rb
Original file line number Diff line number Diff line change
@@ -1,51 +1,10 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/shared_examples_for_base_form'

RSpec.describe SimpleFormsApi::VBA2010207 do
describe 'zip_code_is_us_based' do
subject(:zip_code_is_us_based) { described_class.new(data).zip_code_is_us_based }

context 'veteran address is present and in US' do
let(:data) { { 'veteran_mailing_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'veteran address is present and not in US' do
let(:data) { { 'veteran_mailing_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'non-veteran address is present and in US' do
let(:data) { { 'non_veteran_mailing_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'non-veteran address is present and not in US' do
let(:data) { { 'non_veteran_mailing_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'no valid address is given' do
let(:data) { {} }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end
end
it_behaves_like 'zip_code_is_us_based', %w[veteran_mailing_address non_veteran_mailing_address]

describe 'requester_signature' do
statement_of_truth_signature = 'John Veteran'
Expand Down
65 changes: 2 additions & 63 deletions modules/simple_forms_api/spec/models/vba_21_0845_spec.rb
Original file line number Diff line number Diff line change
@@ -1,69 +1,8 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/shared_examples_for_base_form'

RSpec.describe SimpleFormsApi::VBA210845 do
describe 'zip_code_is_us_based' do
subject(:zip_code_is_us_based) { described_class.new(data).zip_code_is_us_based }

context 'authorizer address is present and in US' do
let(:data) { { 'authorizer_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'authorizer address is present and not in US' do
let(:data) { { 'authorizer_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'person is present and in US' do
let(:data) { { 'person_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'person is present and not in US' do
let(:data) { { 'person_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'organization is present and in US' do
let(:data) do
{ 'organization_address' => { 'country' => 'USA' } }
end

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'organization is present and not in US' do
let(:data) do
{ 'organization_address' => { 'country' => 'Canada' } }
end

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'no valid address is given' do
let(:data) { {} }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end
end
it_behaves_like 'zip_code_is_us_based', %w[authorizer_address person_address organization_address]
end
47 changes: 3 additions & 44 deletions modules/simple_forms_api/spec/models/vba_21_0966_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/shared_examples_for_base_form'

RSpec.describe SimpleFormsApi::VBA210966 do
it_behaves_like 'zip_code_is_us_based', %w[veteran_mailing_address surviving_dependent_mailing_address]

describe 'populate_veteran_data' do
context 'data does not already have what it needs' do
let(:expected_first_name) { 'Rory' }
Expand Down Expand Up @@ -50,48 +53,4 @@
end
end
end

describe 'zip_code_is_us_based' do
subject(:zip_code_is_us_based) { described_class.new(data).zip_code_is_us_based }

context 'veteran address is present and in US' do
let(:data) { { 'veteran_mailing_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'veteran address is present and not in US' do
let(:data) { { 'veteran_mailing_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'surviving dependent is present and in US' do
let(:data) { { 'surviving_dependent_mailing_address' => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'surviving dependent is present and not in US' do
let(:data) { { 'surviving_dependent_mailing_address' => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end

context 'no valid address is given' do
let(:data) { {} }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end
end
end
3 changes: 3 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_4140_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/shared_examples_for_base_form'

RSpec.describe SimpleFormsApi::VBA214140 do
subject(:form) { described_class.new(data) }
Expand All @@ -10,6 +11,8 @@
end
let(:data) { JSON.parse(fixture_path.read) }

it_behaves_like 'zip_code_is_us_based', %w[address]

describe '#data' do
subject { form.data }

Expand Down
5 changes: 4 additions & 1 deletion modules/simple_forms_api/spec/models/vba_40_0247_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/shared_examples_for_base_form'

RSpec.describe SimpleFormsApi::VBA400247 do
it_behaves_like 'zip_code_is_us_based', %w[applicant_address]

RSpec.describe 'SimpleFormsApi::VBA400247' do
describe 'handle_attachments' do
it 'saves the combined pdf' do
original_pdf = double('HexaPDF::Document')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@

describe 'unauthenticated forms' do
unauthenticated_forms.each do |form|
include_examples 'form submission', form, false
it_behaves_like 'form submission', form, false
end
end

describe 'authenticated forms' do
authenticated_forms.each do |form|
include_examples 'form submission', form, true
it_behaves_like 'form submission', form, true
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

RSpec.shared_examples 'zip_code_is_us_based' do |address_keys|
subject(:zip_code_is_us_based) { described_class.new(data).zip_code_is_us_based }

address_keys.each do |address_key|
context 'address is present and in US' do
let(:data) { { address_key => { 'country' => 'USA' } } }

it 'returns true' do
expect(zip_code_is_us_based).to eq(true)
end
end

context 'address is present and not in US' do
let(:data) { { address_key => { 'country' => 'Canada' } } }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end
end

context 'no valid address is given' do
let(:data) { {} }

it 'returns false' do
expect(zip_code_is_us_based).to eq(false)
end
end
end

0 comments on commit a8d9931

Please sign in to comment.