Browse Source

Add an empty deactivate page and button

pull/976/head
Kat 3 years ago
parent
commit
0664e58d9f
  1. 4
      app/controllers/locations_controller.rb
  2. 6
      app/views/locations/show.html.erb
  3. 0
      app/views/locations/toggle_active.html.erb
  4. 1
      config/routes.rb
  5. 5
      spec/features/schemes_spec.rb

4
app/controllers/locations_controller.rb

@ -20,6 +20,10 @@ class LocationsController < ApplicationController
def show; end def show; end
def deactivate;
render "toggle_active", locals: { action: "deactivate" }
end
def create def create
if date_params_missing?(location_params) || valid_date_params?(location_params) if date_params_missing?(location_params) || valid_date_params?(location_params)
@location = Location.new(location_params) @location = Location.new(location_params)

6
app/views/locations/show.html.erb

@ -21,4 +21,8 @@
<% row.action(text: "Change", href: location_edit_name_path(location_id: @location.id, id: @scheme.id)) if attr[:edit] %> <% row.action(text: "Change", href: location_edit_name_path(location_id: @location.id, id: @scheme.id)) if attr[:edit] %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% if !Rails.env.production? %>
<%= govuk_button_link_to "Deactivate this location", location_deactivate_path(location_id: @location.id, id: @scheme.id), warning: true %>
<% end %>

0
app/views/locations/toggle_active.html.erb

1
config/routes.rb

@ -53,6 +53,7 @@ Rails.application.routes.draw do
resources :locations do resources :locations do
get "edit-name", to: "locations#edit_name" get "edit-name", to: "locations#edit_name"
get "edit-local-authority", to: "locations#edit_local_authority" get "edit-local-authority", to: "locations#edit_local_authority"
get "deactivate", to: "locations#deactivate"
end end
end end

5
spec/features/schemes_spec.rb

@ -777,6 +777,11 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Location name for #{location.postcode}" expect(page).to have_content "Location name for #{location.postcode}"
end end
it "allows to deactivate a location" do
click_link("Deactivate this location")
expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{location.id}/deactivate")
end
context "when I press the back button" do context "when I press the back button" do
before do before do
click_link "Back" click_link "Back"

Loading…
Cancel
Save