Skip to content

Commit c1a4d08

Browse files
committed
Hide vaccination tallies table for admins
1 parent 19e7216 commit c1a4d08

File tree

4 files changed

+47
-29
lines changed

4 files changed

+47
-29
lines changed
Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
<%= govuk_table do |table| %>
2-
<% table.with_head do |head| %>
3-
<% head.with_row do |row| %>
4-
<% row.with_cell(text: "Vaccine") %>
5-
<% row.with_cell(text: "Administered") %>
6-
<% row.with_cell(text: "Default batch") %>
7-
<% end %>
8-
<% end %>
9-
10-
<% table.with_body do |body| %>
11-
<% count_by_vaccine.each do |(vaccine, count)| %>
12-
<% body.with_row do |row| %>
13-
<% row.with_cell do %>
14-
<%= vaccine.brand %>
15-
<% end %>
16-
<% row.with_cell do %>
17-
<%= count %>
1+
<% if policy(VaccinationRecord).new? %>
2+
<div class="nhsuk-u-margin-top-3">
3+
<%= render AppDetailsComponent.new(summary: "Your vaccinations today", expander: true) do %>
4+
<%= govuk_table do |table| %>
5+
<% table.with_head do |head| %>
6+
<% head.with_row do |row| %>
7+
<% row.with_cell(text: "Vaccine") %>
8+
<% row.with_cell(text: "Administered") %>
9+
<% row.with_cell(text: "Default batch") %>
10+
<% end %>
1811
<% end %>
19-
<% row.with_cell do %>
20-
<% batch = default_batch(vaccine) %>
21-
<%= batch&.name || "Not set" %>
22-
<% if batch %>
23-
<%= link_to "Change", batch_session_record_path(session, vaccine.programme, vaccine.method) %>
12+
13+
<% table.with_body do |body| %>
14+
<% count_by_vaccine.each do |(vaccine, count)| %>
15+
<% body.with_row do |row| %>
16+
<% row.with_cell do %>
17+
<%= vaccine.brand %>
18+
<% end %>
19+
<% row.with_cell do %>
20+
<%= count %>
21+
<% end %>
22+
<% row.with_cell do %>
23+
<% batch = default_batch(vaccine) %>
24+
<%= batch&.name || "Not set" %>
25+
<% if batch %>
26+
<%= link_to "Change", batch_session_record_path(session, vaccine.programme, vaccine.method) %>
27+
<% end %>
28+
<% end %>
29+
<% end %>
2430
<% end %>
2531
<% end %>
2632
<% end %>
2733
<% end %>
28-
<% end %>
34+
</div>
2935
<% end %>
36+

app/components/app_vaccinations_summary_table_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(current_user:, session:, request_session:)
1111

1212
attr_reader :session, :request_session, :current_user
1313

14-
delegate :govuk_table, to: :helpers
14+
delegate :govuk_table, :policy, to: :helpers
1515

1616
def count_by_vaccine
1717
vaccines = session.vaccines.active.includes(:programme).order(:brand)

app/views/sessions/record/show.html.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222

2323
<div class="app-grid-column-results">
2424
<%= render AppSessionNeedsReviewWarningComponent.new(session: @session) %>
25-
<div class="nhsuk-u-margin-top-3">
26-
<%= render AppDetailsComponent.new(summary: "Your vaccinations today", expander: true) do %>
27-
<%= render AppVaccinationsSummaryTableComponent.new(current_user:, session: @session, request_session: session) %>
28-
<% end %>
29-
</div>
25+
<%= render AppVaccinationsSummaryTableComponent.new(current_user:, session: @session, request_session: session) %>
3026
<%= render AppSearchResultsComponent.new(@pagy, label: "children") do %>
3127
<% @patient_sessions.each do |patient_session| %>
3228
<%= render AppPatientSessionSearchResultCardComponent.new(

spec/features/tallying_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
then_i_see_my_vaccination_tallies_with_all_zero_values_with_default_batches
2525
end
2626

27+
scenario "when an admin is viewing the record tab for a session" do
28+
given_a_session_for_hpv_and_flu_is_running_today
29+
when_i_visit_the_session_record_tab_as_an_admin
30+
then_i_do_not_see_the_vaccination_tallies_table
31+
end
32+
2733
def given_a_session_for_hpv_and_flu_is_running_today
2834
@flu_programme = create(:programme, :flu, vaccines: [])
2935
@hpv_programme = create(:programme, :hpv, vaccines: [])
@@ -59,6 +65,11 @@ def when_i_visit_the_session_record_tab
5965
visit session_record_path(@session)
6066
end
6167

68+
def when_i_visit_the_session_record_tab_as_an_admin
69+
sign_in @user, role: :medical_secretary
70+
visit session_record_path(@session)
71+
end
72+
6273
def and_click_on_change_default_batch_link
6374
within ".nhsuk-table" do
6475
click_on "Change"
@@ -166,4 +177,8 @@ def then_i_see_my_vaccination_tallies_with_all_zero_values_with_default_batches
166177
def and_i_click_on_the_expander_your_vaccinations_today
167178
find("span", text: "Your vaccinations today").click
168179
end
180+
181+
def then_i_do_not_see_the_vaccination_tallies_table
182+
expect(page).to have_no_content("Your vaccinations today")
183+
end
169184
end

0 commit comments

Comments
 (0)