diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index 43f9983f0..d89612d42 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -22,7 +22,9 @@ <%= summary_list.row do |row| %> <% row.key { attr[:name] } %> <% row.value { details_html(attr) } %> - <% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] && user_can_edit_scheme?(current_user, @scheme) %> + <% if SchemePolicy.new(current_user, @scheme).update? %> + <% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %> + <% end %> <% end %> <% end %> <% end %> diff --git a/spec/views/schemes/show.html.erb_spec.rb b/spec/views/schemes/show.html.erb_spec.rb index 83bc6b6e3..42fa8f54a 100644 --- a/spec/views/schemes/show.html.erb_spec.rb +++ b/spec/views/schemes/show.html.erb_spec.rb @@ -39,5 +39,15 @@ RSpec.describe "schemes/show.html.erb" do expect(rendered).not_to have_content("Deactivate this scheme") end + + it "does not see change answer links" do + assign(:scheme, scheme) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).not_to have_content("Change") + end end end