From 5a6b2f8233c9a585046ba997e99ebb83dc6f2bc4 Mon Sep 17 00:00:00 2001 From: ColinBruce Date: Wed, 25 Oct 2023 15:22:40 +0100 Subject: [PATCH] AP-4359: Update following review Remove some commented out code, revert all tests to use eq and clarify vehicle submissions for partners by extending the comments --- app/services/cfe_civil/components/partner.rb | 17 +++++++++-------- .../cfe_civil/components/capitals_spec.rb | 4 ++-- .../components/irregular_incomes_spec.rb | 4 ---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/services/cfe_civil/components/partner.rb b/app/services/cfe_civil/components/partner.rb index cd1771f543..d91cf7f9b3 100644 --- a/app/services/cfe_civil/components/partner.rb +++ b/app/services/cfe_civil/components/partner.rb @@ -7,14 +7,15 @@ def call return {}.to_json if partner.blank? result = base_partner - result.merge! JSON.parse(Components::CashTransactions.new(@legal_aid_application, "Partner").call) # so far... all other models are stored as Applicant/Partner - result.merge! JSON.parse(Components::IrregularIncomes.new(@legal_aid_application, "Partner").call) # so far... all other models are stored as Applicant/Partner - result.merge! JSON.parse(Components::Vehicles.new(@legal_aid_application, "partner").call) # this is stored as client/partner - result.merge! JSON.parse(Components::Employments.new(@legal_aid_application, "Partner").call) # this is stored as Applicant/Partner - result.merge! JSON.parse(Components::RegularTransactions.new(@legal_aid_application, "Partner").call) # this is stored as Applicant/Partner - result.merge! JSON.parse(Components::Capitals.new(@legal_aid_application, "Partner").call) # this is stored as Applicant/Partner - # employment_details # skipping this is a ccq datatype, we don't use it - # self_employment_details # skipping this is a ccq datatype, we don't use it + # Most records are stored with an Owner field that is tied to Applicant or Partner models, using their IDs + # Vehicles are stored with the, optional, output of a radio button as client or partner (lower cased) + # For this reason the call to Components::Vehicles.new is slightly different from the rest of the generators + result.merge! JSON.parse(Components::CashTransactions.new(@legal_aid_application, "Partner").call) + result.merge! JSON.parse(Components::IrregularIncomes.new(@legal_aid_application, "Partner").call) + result.merge! JSON.parse(Components::Vehicles.new(@legal_aid_application, "partner").call) + result.merge! JSON.parse(Components::Employments.new(@legal_aid_application, "Partner").call) + result.merge! JSON.parse(Components::RegularTransactions.new(@legal_aid_application, "Partner").call) + result.merge! JSON.parse(Components::Capitals.new(@legal_aid_application, "Partner").call) # Outgoings # skipped, these are generated from Truelayer and that is not currently supported by the partner flow # state_benefits # skipped, these are generated from Truelayer and that is not currently supported by the partner flow # other_incomes # skipped, these are generated from Truelayer and that is not currently supported by the partner flow diff --git a/spec/services/cfe_civil/components/capitals_spec.rb b/spec/services/cfe_civil/components/capitals_spec.rb index 4996fad623..e8254fce59 100644 --- a/spec/services/cfe_civil/components/capitals_spec.rb +++ b/spec/services/cfe_civil/components/capitals_spec.rb @@ -61,7 +61,7 @@ subject(:call) { described_class.call(legal_aid_application, "Partner") } it "returns json in the expected format with the partner and joint bank values merged" do - expect(call).to match_json_expression({ + expect(call).to eq({ capitals: { bank_accounts: [ { description: "Partner current accounts", value: offline_partner_current_balance.to_s }, @@ -71,7 +71,7 @@ ], non_liquid_capital: [], }, - }) + }.to_json) end end end diff --git a/spec/services/cfe_civil/components/irregular_incomes_spec.rb b/spec/services/cfe_civil/components/irregular_incomes_spec.rb index b59095b3e8..346af34c72 100644 --- a/spec/services/cfe_civil/components/irregular_incomes_spec.rb +++ b/spec/services/cfe_civil/components/irregular_incomes_spec.rb @@ -21,10 +21,6 @@ context "when both applicant and partner record student finance" do let(:applicant) { create(:applicant, student_finance: true, student_finance_amount: 3628.07) } let(:partner) { create(:partner, student_finance: true, student_finance_amount: 1234.56) } - # before do - # create(:applicant, student_finance: true, student_finance_amount: 3628.07) - # create(:partner, student_finance: true, student_finance_amount: 1234.56) - # end context "when no owner type is specified" do it "returns the expected JSON block with only the applicant data" do