Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/operations/fdsh/ssa_vlp/rj3/process_applicant_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ProcessApplicantRequests
US_CITIZEN_STATUS = 'us_citizen'

NON_CITIZEN_STATUS = %w[naturalized_citizen alien_lawfully_present not_lawfully_present_in_us non_native_not_lawfully_present_in_us].freeze
SSA_EVIDENCE_KEYS = %w[social_security_number_evidence citizenship_evidence].freeze
SSA_EVIDENCE_KEYS = %w[social_security_number_evidence].freeze
Comment thread
jacobkagon marked this conversation as resolved.

def call(params)
@values, @job, @application, @applicant_entity = yield validate_params(params)
Expand Down Expand Up @@ -83,7 +83,7 @@ def eligible_for_invoking_ssa?
return false unless eligibility
return false unless ssa_evidences?

encrypted_ssn.present? || citizen_status == US_CITIZEN_STATUS
encrypted_ssn.present?
end

def eligible_for_invoking_dhs?
Expand Down
120 changes: 52 additions & 68 deletions spec/operations/fdsh/ssa_vlp/rj3/process_applicant_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,55 +303,39 @@
subject.instance_variable_set(:@applicant_entity, applicant_entity)
end

context 'when all conditions are met' do
it 'returns true for US citizen with encrypted SSN' do
allow(subject).to receive(:eligibility).and_return(eligibility)
context 'when applicant has SSA evidences' do
before do
allow(subject).to receive(:ssa_evidences?).and_return(true)
allow(subject).to receive(:encrypted_ssn).and_return('encrypted_ssn_value')
allow(subject).to receive(:citizen_status).and_return('us_citizen')

expect(subject.send(:eligible_for_invoking_ssa?)).to be true
end

it 'returns true for US citizen without encrypted SSN' do
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:ssa_evidences?).and_return(true)
allow(subject).to receive(:encrypted_ssn).and_return(nil)
allow(subject).to receive(:citizen_status).and_return('us_citizen')

expect(subject.send(:eligible_for_invoking_ssa?)).to be true
end

it 'returns true for non-citizen with encrypted SSN' do
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:ssa_evidences?).and_return(true)
allow(subject).to receive(:encrypted_ssn).and_return('encrypted_ssn_value')
allow(subject).to receive(:citizen_status).and_return('naturalized_citizen')
context 'when applicant has encrypted SSN' do
before do
allow(subject).to receive(:encrypted_ssn).and_return('encrypted_ssn_value')
end

expect(subject.send(:eligible_for_invoking_ssa?)).to be true
it 'returns true' do
expect(subject.send(:eligible_for_invoking_ssa?)).to be true
end
end
end

context 'when conditions are not met' do
it 'returns false when no eligibility' do
allow(subject).to receive(:eligibility).and_return(nil)
context 'when applicant does not have encrypted SSN' do
before do
allow(subject).to receive(:encrypted_ssn).and_return(nil)
end

expect(subject.send(:eligible_for_invoking_ssa?)).to be false
it 'returns false' do
expect(subject.send(:eligible_for_invoking_ssa?)).to be false
end
end
end

it 'returns false when no SSA evidences' do
allow(subject).to receive(:eligibility).and_return(eligibility)
context 'when applicant does not have SSA evidences' do
before do
allow(subject).to receive(:ssa_evidences?).and_return(false)

expect(subject.send(:eligible_for_invoking_ssa?)).to be false
end

it 'returns false when no encrypted SSN and not US citizen' do
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:ssa_evidences?).and_return(true)
allow(subject).to receive(:encrypted_ssn).and_return(nil)
allow(subject).to receive(:citizen_status).and_return('naturalized_citizen')

it 'returns false' do
expect(subject.send(:eligible_for_invoking_ssa?)).to be false
end
end
Expand All @@ -365,56 +349,56 @@
subject.instance_variable_set(:@applicant_entity, applicant_entity)
end

context 'when all conditions are met' do
it 'returns true for non-citizen applying for coverage with immigration evidence' do
allow(subject).to receive(:applicant_applying_coverage?).and_return(true)
context 'when applicant has DHS evidences' do
before do
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:immigration_evidence?).and_return(true)
allow(subject).to receive(:citizen_status).and_return('naturalized_citizen')

expect(subject.send(:eligible_for_invoking_dhs?)).to be true
end

%w[naturalized_citizen alien_lawfully_present not_lawfully_present_in_us non_native_not_lawfully_present_in_us].each do |status|
it "returns true for #{status} status" do
context 'when applicant is applying for coverage' do
before do
allow(subject).to receive(:applicant_applying_coverage?).and_return(true)
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:immigration_evidence?).and_return(true)
allow(subject).to receive(:citizen_status).and_return(status)
end

expect(subject.send(:eligible_for_invoking_dhs?)).to be true
context 'when applicant has non-citizen status' do
before do
allow(subject).to receive(:citizen_status).and_return('alien_lawfully_present')
end

it 'returns true' do
expect(subject.send(:eligible_for_invoking_dhs?)).to be true
end
end
end
end

context 'when conditions are not met' do
it 'returns false when not applying for coverage' do
allow(subject).to receive(:applicant_applying_coverage?).and_return(false)
context 'when applicant does not have non-citizen status' do
before do
allow(subject).to receive(:citizen_status).and_return('us_citizen')
end

expect(subject.send(:eligible_for_invoking_dhs?)).to be false
it 'returns false' do
expect(subject.send(:eligible_for_invoking_dhs?)).to be false
end
end
end

it 'returns false when no eligibility' do
allow(subject).to receive(:applicant_applying_coverage?).and_return(true)
allow(subject).to receive(:eligibility).and_return(nil)
context 'when applicant is not applying for coverage' do
before do
allow(subject).to receive(:applicant_applying_coverage?).and_return(false)
end

expect(subject.send(:eligible_for_invoking_dhs?)).to be false
it 'returns false' do
expect(subject.send(:eligible_for_invoking_dhs?)).to be false
end
end
end

it 'returns false when no immigration evidence' do
allow(subject).to receive(:applicant_applying_coverage?).and_return(true)
context 'when applicant does not have DHS evidences' do
before do
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:immigration_evidence?).and_return(false)

expect(subject.send(:eligible_for_invoking_dhs?)).to be false
end

it 'returns false for US citizen status' do
allow(subject).to receive(:applicant_applying_coverage?).and_return(true)
allow(subject).to receive(:eligibility).and_return(eligibility)
allow(subject).to receive(:immigration_evidence?).and_return(true)
allow(subject).to receive(:citizen_status).and_return('us_citizen')

it 'returns false' do
expect(subject.send(:eligible_for_invoking_dhs?)).to be false
end
end
Expand Down
Loading