Browse Source

Add delete button to CYA

pull/2285/head
Kat 2 years ago
parent
commit
adc4bf01b9
  1. 4
      app/views/locations/check_answers.html.erb
  2. 17
      spec/requests/locations_controller_spec.rb

4
app/views/locations/check_answers.html.erb

@ -45,3 +45,7 @@
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div>
<% end %>
<% if LocationPolicy.new(current_user, @location).delete? %>
<%= delete_location_link(@location) %>
<% end %>

17
spec/requests/locations_controller_spec.rb

@ -1405,6 +1405,23 @@ RSpec.describe LocationsController, type: :request do
expect(page).to have_content("Check your answers")
end
context "with an active location" do
it "does not render delete this location" do
expect(location.status).to eq(:active)
expect(page).not_to have_link("Delete this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/delete-confirmation")
end
end
context "with an incomplete location" do
it "renders delete this location" do
location.update!(units: nil)
get "/schemes/#{scheme.id}/locations/#{location.id}/check-answers"
expect(location.reload.status).to eq(:incomplete)
expect(page).to have_link("Delete this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/delete-confirmation")
end
end
context "when location is confirmed" do
let(:params) { { location: { confirmed: true } } }

Loading…
Cancel
Save