diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index f9f987617..32c579a60 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -15,9 +15,13 @@ class LocationsController < ApplicationController end def new - @location = Location.new(scheme: @scheme) + @location = if params[:referrer] == "new_scheme" && @scheme.locations.present? + @scheme.locations.first + else + Location.new(scheme: @scheme) + end @location.save! - redirect_to scheme_location_postcode_path(@scheme, @location) + redirect_to scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]) end def postcode diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 389446b7f..fd5c1a2c1 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -229,7 +229,7 @@ private when "secondary-client-group" scheme_support_path(@scheme) when "support" - new_scheme_location_path(@scheme) + new_scheme_location_path(@scheme, referrer: "new_scheme") when "details" if @scheme.arrangement_type_before_type_cast == "D" scheme_primary_client_group_path(@scheme) diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index a8e8a11c0..2804bc0ba 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -52,7 +52,7 @@ <%= table.body do |body| %> <%= body.row do |row| %> <% row.cell(text: location.id) %> - <% row.cell(text: simple_format(location_cell_postcode(location, location.incomplete? ? scheme_location_check_answers_path(@scheme, location) : scheme_location_path(@scheme, location)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(location_cell_postcode(location, location.confirmed ? scheme_location_path(@scheme, location) : scheme_location_check_answers_path(@scheme, location)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: location.units) %> <% row.cell(text: simple_format("#{location.type_of_unit}")) %> <% row.cell(text: location.mobility_type) %> diff --git a/app/views/locations/postcode.html.erb b/app/views/locations/postcode.html.erb index c7c5ccad4..bdebfd87b 100644 --- a/app/views/locations/postcode.html.erb +++ b/app/views/locations/postcode.html.erb @@ -3,7 +3,14 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_locations_path(@scheme), + href: case params[:referrer] + when "check_answers" + scheme_location_check_answers_path(@scheme, @location) + when "new_scheme" + scheme_support_path(@scheme) + else + scheme_locations_path(@scheme) + end ) %> <% end %> diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index e68893153..8260cf538 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -456,7 +456,7 @@ RSpec.describe "Schemes scheme Features" do end it "lets me add location" do - expect(page).to have_content "Add a location to this scheme" + expect(page).to have_content "Add a location to FooBar" end it "lets me navigate back to support questions" do