Browse Source

navigation when editing location

pull/704/head
JG 3 years ago
parent
commit
ab5ef95141
  1. 8
      app/controllers/locations_controller.rb
  2. 2
      config/routes.rb
  3. 1
      spec/models/location_spec.rb

8
app/controllers/locations_controller.rb

@ -19,7 +19,13 @@ class LocationsController < ApplicationController
end
def details
render :new
@scheme = Scheme.find(params[:scheme_id])
@location = Location.find(params[:id])
end
def update
@scheme = Scheme.find(params[:scheme_id])
redirect_to scheme_check_answers_path(@scheme, anchor: "locations")
end
private

2
config/routes.rb

@ -47,8 +47,8 @@ Rails.application.routes.draw do
get "locations", to: "schemes#locations"
get "location/new", to: "locations#new"
post "location/create", to: "locations#create"
patch "location", to: "locations#create"
get "location", to: "locations#details"
patch "location", to: "locations#update"
end
end

1
spec/models/location_spec.rb

@ -11,6 +11,7 @@ RSpec.describe Location, type: :model do
describe "#validate_postcode" do
let(:location) { FactoryBot.build(:location) }
it "does not add an error if postcode is valid" do
location.postcode = "M1 1AE"
location.save

Loading…
Cancel
Save