Skip to content

Commit

Permalink
ap-5338: add parental_responsibility_evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
kmahern committed Nov 13, 2024
1 parent 90104a5 commit 54927b4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/application_digest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ApplicationDigest < ApplicationRecord
parental_responsibility_agreement
parental_responsibility_court_order
child_subject
parental_responsibility_evidence
autogranted
].freeze

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/services/reports/mis/application_detail_csv_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions spec/factories/attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
10 changes: 9 additions & 1 deletion spec/models/application_digest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -537,20 +537,26 @@
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
expect(digest.biological_parent).to be false
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

Expand All @@ -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

Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions spec/models/legal_aid_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spec/services/reports/mis/application_detail_csv_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 54927b4

Please sign in to comment.