diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index d1a953565..09db1c465 100644 --- a/app/controllers/locations_controller.rb +++ b/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 diff --git a/config/routes.rb b/config/routes.rb index 8e5fa919a..db8cb3dad 100644 --- a/config/routes.rb +++ b/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 diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index 726349799..2e57e9d66 100644 --- a/spec/models/location_spec.rb +++ b/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