Skip to content

Commit

Permalink
Ensure notices are always visible (#2726)
Browse files Browse the repository at this point in the history
This fixes a bug were notices were only visible if there was at least
one deceased patient, and wouldn't show if there were only restricted or
invalidated patients.
  • Loading branch information
tvararu authored Dec 13, 2024
2 parents b729630 + a011874 commit 0bcb2f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/views/notices/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= h1 t("notices.index.title"), size: "xl" %>

<% if @deceased_patients.any? %>
<% if @deceased_patients.any? || @invalidated_patients.any? || @restricted_patients.any? %>
<%= render AppNoticesTableComponent.new(deceased_patients: @deceased_patients, invalidated_patients: @invalidated_patients, restricted_patients: @restricted_patients) %>
<% else %>
<p class="nhsuk-body"><%= t("notices.index.no_results") %></p>
Expand Down
34 changes: 25 additions & 9 deletions spec/features/manage_children_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,34 @@
then_i_see_permission_denied
end

scenario "Viewing important notices as a superuser" do
scenario "Viewing deceased patient notices as a superuser" do
when_i_go_to_the_dashboard_as_a_superuser
and_i_click_on_notices
then_i_see_no_notices

when_a_deceased_patient_exists
and_an_invalid_patient_exists
and_a_restricted_patient_exists
and_i_click_on_notices
then_i_see_the_notice_of_date_of_death
and_i_see_the_notice_of_invalid
and_i_see_the_notice_of_sensitive
end

scenario "Viewing invalidated patient notices as a superuser" do
when_i_go_to_the_dashboard_as_a_superuser
and_i_click_on_notices
then_i_see_no_notices

when_an_invalidated_patient_exists
and_i_click_on_notices
then_i_see_the_notice_of_invalid
end

scenario "Viewing restricted patient notices as a superuser" do
when_i_go_to_the_dashboard_as_a_superuser
and_i_click_on_notices
then_i_see_no_notices

when_a_restricted_patient_exists
and_i_click_on_notices
then_i_see_the_notice_of_sensitive
end

def given_my_organisation_exists
Expand Down Expand Up @@ -121,12 +137,12 @@ def when_a_deceased_patient_exists
@deceased_patient = create(:patient, :deceased, organisation: @organisation)
end

def and_an_invalid_patient_exists
def when_an_invalidated_patient_exists
@invalidated_patient =
create(:patient, :invalidated, organisation: @organisation)
end

def and_a_restricted_patient_exists
def when_a_restricted_patient_exists
@restricted_patient =
create(:patient, :restricted, organisation: @organisation)
end
Expand Down Expand Up @@ -267,12 +283,12 @@ def then_i_see_the_notice_of_date_of_death
expect(page).to have_content("Record updated with child’s date of death")
end

def and_i_see_the_notice_of_invalid
def then_i_see_the_notice_of_invalid
expect(page).to have_content(@invalidated_patient.full_name)
expect(page).to have_content("Record flagged as invalid")
end

def and_i_see_the_notice_of_sensitive
def then_i_see_the_notice_of_sensitive
expect(page).to have_content(@restricted_patient.full_name)
expect(page).to have_content("Record flagged as sensitive")
end
Expand Down

0 comments on commit 0bcb2f4

Please sign in to comment.