diff --git a/app/models/application_digest.rb b/app/models/application_digest.rb index 83002fddd9..e3e9d125fd 100644 --- a/app/models/application_digest.rb +++ b/app/models/application_digest.rb @@ -18,6 +18,7 @@ class ApplicationDigest < ApplicationRecord parental_responsibility_agreement parental_responsibility_court_order child_subject + parental_responsibility_evidence autogranted ].freeze @@ -73,6 +74,7 @@ def map_attrs(application_id) parental_responsibility_agreement: laa.parental_responsibility_agreement_relationship?, parental_responsibility_court_order: laa.parental_responsibility_court_order_relationship?, child_subject: laa.child_subject_relationship?, + parental_responsibility_evidence: laa.parental_responsibility_evidence?, autogranted: laa.auto_grant_special_children_act?(nil), } end diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 3e8795e583..7ffd6721b0 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -178,6 +178,7 @@ def self.header_row "Parental responsibility agreement relationship?", "Parental responsibility court order relationship?", "Child subject relationship?", + "Parental responsibility evidence?", "Autogranted?", ] end @@ -473,11 +474,15 @@ def sca @line << yesno(laa.parental_responsibility_agreement_relationship?) @line << yesno(laa.parental_responsibility_court_order_relationship?) @line << yesno(laa.child_subject_relationship?) + @line << if laa.parental_responsibility_agreement_relationship? || laa.parental_responsibility_court_order_relationship? + yesno(laa.parental_responsibility_evidence?) + end else @line << nil @line << nil @line << nil @line << nil + @line << nil end end diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb index ba591aeb88..6e5b3d8e14 100644 --- a/spec/factories/attachments.rb +++ b/spec/factories/attachments.rb @@ -32,6 +32,12 @@ attachment_name { "bank_transaction_report.csv" } end + trait :parental_responsibility do + attachment_type { "parental_responsibility" } + sequence(:attachment_name) { |n| "parental_responsibility_#{n}" } + sequence(:original_filename) { "original_filename.pdf" } + end + trait :uploaded_evidence_collection do attachment_type { "uncategorised" } attachment_name { "uploaded_evidence_collection" } diff --git a/spec/models/application_digest_spec.rb b/spec/models/application_digest_spec.rb index 6fc82db312..6826a82447 100644 --- a/spec/models/application_digest_spec.rb +++ b/spec/models/application_digest_spec.rb @@ -537,13 +537,18 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be false end end context "when the application has a proceeding with relationship_to_child parental_responsibility_agreement" do let(:relationship_to_child) { "parental_responsibility_agreement" } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } - before { laa.proceedings << sca_proceeding } + before do + laa.proceedings << sca_proceeding + laa.attachments << parental_responsibility_evidence + end it "returns the expected data" do application_digest @@ -551,6 +556,7 @@ expect(digest.parental_responsibility_agreement).to be true expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be true end end @@ -565,6 +571,7 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be true expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be false end end @@ -579,6 +586,7 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be true + expect(digest.parental_responsibility_evidence).to be false end end end diff --git a/spec/models/legal_aid_application_spec.rb b/spec/models/legal_aid_application_spec.rb index 28d5275324..daa54d6ba2 100644 --- a/spec/models/legal_aid_application_spec.rb +++ b/spec/models/legal_aid_application_spec.rb @@ -2258,6 +2258,21 @@ end end + describe "#parental_responsibility_evidence?" do + subject { legal_aid_application.parental_responsibility_evidence? } + + context "with aan application that has parental responsibility evidence" do + let(:legal_aid_application) { create(:legal_aid_application, attachments: [parental_responsibility_evidence]) } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } + + it { is_expected.to be true } + end + + context "without a proceeding with a child_subject relationship" do + it { is_expected.to be false } + end + end + private def uploaded_evidence_output diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index 48e0280c8a..5c4223f9ec 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -878,6 +878,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to be_nil expect(value_for("Parental responsibility court order relationship?")).to be_nil expect(value_for("Child subject relationship?")).to be_nil + expect(value_for("Parental responsibility evidence?")).to be_nil end end @@ -894,6 +895,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to be_nil end end @@ -905,17 +907,22 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "Yes" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to eq "No" end end context "when the application has a proceeding with relationship_to_child court_order" do let(:relationship_to_child) { "court_order" } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } + + before { legal_aid_application.attachments << parental_responsibility_evidence } it "returns the expected data" do expect(value_for("Biological parent relationship?")).to eq "No" expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "Yes" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to eq "Yes" end end @@ -927,6 +934,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "Yes" + expect(value_for("Parental responsibility evidence?")).to be_nil end end end