From 5a610e6ae88842eff3c733d71bfe89ae3ece4c5f Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 18 May 2023 16:09:43 +0100 Subject: [PATCH] hide change location answers from providers --- app/views/locations/show.html.erb | 22 ++++++++++++---------- spec/views/locations/show.html.erb_spec.rb | 11 +++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index ca2429fed..0be68ffe5 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -10,17 +10,19 @@ <%= render partial: "organisations/headings", locals: { main: @location.postcode, sub: @location.name } %>
-
- <%= govuk_summary_list do |summary_list| %> - <% display_location_attributes(@location).each do |attr| %> - <%= summary_list.row do |row| %> - <% row.key { attr[:name] } %> - <% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %> - <% row.action(text: "Change", href: scheme_location_name_path(@scheme, @location, referrer: "details")) if attr[:attribute] == "name" && user_can_edit_scheme?(current_user, @scheme) %> - <% end %> - <% end %> +
+ <%= govuk_summary_list do |summary_list| %> + <% display_location_attributes(@location).each do |attr| %> + <%= summary_list.row do |row| %> + <% row.key { attr[:name] } %> + <% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %> + <% if LocationPolicy.new(current_user, @location).update? %> + <% row.action(text: "Change", href: scheme_location_name_path(@scheme, @location, referrer: "details")) if attr[:attribute] == "name" %> + <% end %> <% end %> -
+ <% end %> + <% end %> +
<% if FeatureToggle.location_toggle_enabled? %> diff --git a/spec/views/locations/show.html.erb_spec.rb b/spec/views/locations/show.html.erb_spec.rb index 0a17c248a..ad8540eeb 100644 --- a/spec/views/locations/show.html.erb_spec.rb +++ b/spec/views/locations/show.html.erb_spec.rb @@ -53,5 +53,16 @@ RSpec.describe "locations/show.html.erb" do expect(rendered).not_to have_content("Deactivate this location") end + + it "does not see change answer links" do + assign(:scheme, scheme) + assign(:location, location) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).not_to have_content("Change") + end end end