diff --git a/app/services/ccms/attribute_value_generator.rb b/app/services/ccms/attribute_value_generator.rb index 6a1a9e5b24..db5272f251 100644 --- a/app/services/ccms/attribute_value_generator.rb +++ b/app/services/ccms/attribute_value_generator.rb @@ -30,6 +30,7 @@ class AttributeValueGenerator |dependant |opponent |domestic_abuse_summary + |partner |parties_mental_capacity |other_assets_declaration |other_party @@ -41,6 +42,7 @@ class AttributeValueGenerator |wage_slip )_(\S+)$}x APPLICANT_REGEX = /^applicant_(\S+)$/ + PARTNER_REGEX = /^partner_(\S+)$/ APPLICATION_REGEX = /^application_(\S+)$/ BANK_REGEX = /^bank_account_(\S+)$/ LEAD_PROCEEDING = /^lead_proceeding_(\S+)$/ @@ -387,6 +389,10 @@ def applicant @applicant ||= legal_aid_application.applicant end + def partner + @partner ||= legal_aid_application.partner + end + def standardly_named_method?(method) STANDARD_METHOD_NAMES.match?(method) end @@ -427,6 +433,8 @@ def call_standard_method(method, options) legal_aid_application.__send__(Regexp.last_match(1)) when APPLICANT_REGEX applicant.__send__(Regexp.last_match(1)) + when PARTNER_REGEX + partner.__send__(Regexp.last_match(1)) when BANK_REGEX options[:bank_acct].__send__(Regexp.last_match(1)) when CHANCES_OF_SUCCESS diff --git a/config/ccms/attribute_block_configs/base.yml b/config/ccms/attribute_block_configs/base.yml index b731ba5ff6..43e1dc2dde 100644 --- a/config/ccms/attribute_block_configs/base.yml +++ b/config/ccms/attribute_block_configs/base.yml @@ -1332,10 +1332,28 @@ global_means: response_type: boolean user_defined: false GB_INPUT_B_5WP1_3A: - value: false + value: '#applicant_has_partner?' br100_meaning: 'Client: The client has a partner?' response_type: boolean user_defined: true + GB_INPUT_T_5WP1_5A: + generate_block?: '#applicant_has_partner?' + value: '#partner_first_name' + br100_meaning: 'Client: The client has a partner?' + response_type: text + user_defined: true + GB_INPUT_T_5WP1_6A: + generate_block?: '#applicant_has_partner?' + value: '#partner_last_name' + br100_meaning: 'Client: The client has a partner?' + response_type: text + user_defined: true + GB_INPUT_D_5WP1_8A: + generate_block?: '#applicant_has_partner?' + value: '#partner_date_of_birth' + br100_meaning: 'Client: The client has a partner?' + response_type: date + user_defined: true CLIENT_VULNERABLE: generate_block?: false value: false diff --git a/spec/services/ccms/requestors/case_add_requestor_xml_blocks/passported_attributes_spec.rb b/spec/services/ccms/requestors/case_add_requestor_xml_blocks/passported_attributes_spec.rb index d12413c6f4..f3aec3bdf1 100644 --- a/spec/services/ccms/requestors/case_add_requestor_xml_blocks/passported_attributes_spec.rb +++ b/spec/services/ccms/requestors/case_add_requestor_xml_blocks/passported_attributes_spec.rb @@ -1733,6 +1733,73 @@ module Requestors end end end + + describe "Partner values" do + context "when the applicant has a partner" do + before do + create(:partner, first_name: "Rupert", last_name: "Giles", date_of_birth: Date.new(1955, 4, 11), legal_aid_application:) + legal_aid_application.applicant.update!(has_partner: true) + end + + describe "GB_INPUT_B_5WP1_3A - Client: The client has a partner?" do + it "returns true" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_B_5WP1_3A") + expect(block).to have_boolean_response true + end + end + + describe "GB_INPUT_T_5WP1_5A - Partner: First name" do + it "is populated with the partners details" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_T_5WP1_5A") + expect(block).to have_text_response "Rupert" + end + end + + describe "GB_INPUT_T_5WP1_6A - Partner: Last name" do + it "is populated with the partners details" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_T_5WP1_6A") + expect(block).to have_text_response "Giles" + end + end + + describe "GB_INPUT_D_5WP1_8A - Partner: DOB" do + it "is populated with the partners details" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_D_5WP1_8A") + expect(block).to have_date_response "11-04-1955" + end + end + end + + context "when the applicant does not have a partner" do + describe "GB_INPUT_B_5WP1_3A - Client: The client has a partner?" do + it "returns false" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_B_5WP1_3A") + expect(block).to have_boolean_response false + end + end + + describe "GB_INPUT_T_5WP1_5A - Partner: First name" do + it "is not returned" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_T_5WP1_5A") + expect(block).not_to be_present, "Expected block for attribute GB_INPUT_T_5WP1_5A not to be generated, but was \n #{block}" + end + end + + describe "GB_INPUT_T_5WP1_6A - Partner: Surname" do + it "is not returned" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_T_5WP1_6A") + expect(block).not_to be_present, "Expected block for attribute GB_INPUT_T_5WP1_6A not to be generated, but was \n #{block}" + end + end + + describe "GB_INPUT_T_5WP1_8A - Partner: DOB" do + it "is not returned" do + block = XmlExtractor.call(xml, :global_means, "GB_INPUT_T_5WP1_8A") + expect(block).not_to be_present, "Expected block for attribute GB_INPUT_T_5WP1_8A not to be generated, but was \n #{block}" + end + end + end + end end def omitted_attributes