Skip to content

Commit b7b85d5

Browse files
committed
Ensure Gillick assessment is only shown on day
This is a follow up to #6576 which missed that the UI would still show the Gillick assessment on a different day. Although the original bug has been fixed (self-consent cannot be given on a different day), the child would show as Gillick assessed still, which is not the case. Jira-Issue: MAV-6741
1 parent 393b993 commit b7b85d5

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

app/components/app_gillick_assessment_component.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def gillick_assessment
1919
.gillick_assessments
2020
.order(created_at: :desc)
2121
.for_session(session)
22+
.where(date: Date.current)
2223
.for_programme(programme)
2324
.first
2425
end

spec/components/app_gillick_assessment_component_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,25 @@
1515
let(:patient) { create(:patient) }
1616
let(:session) { create(:session, :today, programmes:) }
1717

18-
before { create(:gillick_assessment, :competent, patient:, session:) }
18+
let(:date) { Date.current }
19+
20+
before do
21+
create(:gillick_assessment, :competent, patient:, session:, date:)
22+
end
1923

2024
context "with a nurse user" do
2125
before { stub_authorization(allowed: true) }
2226

23-
it { should have_link("Edit Gillick competence") }
2427
it { should have_heading("Gillick assessment") }
28+
it { should have_link("Edit Gillick competence") }
29+
it { should have_content("Child assessed as Gillick competent") }
30+
31+
context "when the assessment is for a different day" do
32+
let(:date) { Date.yesterday }
33+
34+
it { should have_link("Assess Gillick competence") }
35+
it { should_not have_content("Child assessed as Gillick competent") }
36+
end
2537
end
2638

2739
context "with an admin user" do

0 commit comments

Comments
 (0)