Skip to content

Commit

Permalink
Merge pull request #5949 from ministryofjustice/ap-3887/ccms-partner-…
Browse files Browse the repository at this point in the history
…submission

AP-3887: Add Partner CCMS values
  • Loading branch information
colinbruce authored Nov 8, 2023
2 parents 2c88215 + 2e0afd7 commit 560cc33
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/services/ccms/attribute_value_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AttributeValueGenerator
|dependant
|opponent
|domestic_abuse_summary
|partner
|parties_mental_capacity
|other_assets_declaration
|other_party
Expand All @@ -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+)$/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion config/ccms/attribute_block_configs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 560cc33

Please sign in to comment.