diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 7b13353f6..0d3ede8bb 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -15,13 +15,9 @@ class LocationsController < ApplicationController end def new - @location = if params[:referrer] == "new_scheme" && @scheme.locations.present? - @scheme.locations.first - else - Location.new(scheme: @scheme) - end + @location = Location.new(scheme: @scheme) @location.save! - redirect_to scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_postcode_path(@scheme, @location, route: params[:route]) end def postcode @@ -32,11 +28,11 @@ class LocationsController < ApplicationController if @location.valid?(:postcode) @location.save! if @location.location_code.blank? || @location.location_admin_district.blank? - redirect_to scheme_location_local_authority_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_local_authority_path(@scheme, @location, route: params[:route], referrer: params[:referrer]) elsif params[:referrer] == "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else - redirect_to scheme_location_name_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_name_path(@scheme, @location, route: params[:route]) end else render :postcode, status: :unprocessable_entity @@ -50,10 +46,10 @@ class LocationsController < ApplicationController @location.location_code = Location.local_authorities.key(params[:location][:location_admin_district]) if @location.valid?(:location_admin_district) @location.save! - if params[:referrer] == "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + if params[:referrer] == "check_answers" || params[:referrer] == "check_local_authority" + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else - redirect_to scheme_location_name_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_name_path(@scheme, @location, route: params[:route]) end else render :local_authority, status: :unprocessable_entity @@ -68,11 +64,11 @@ class LocationsController < ApplicationController @location.save! case params[:referrer] when "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) when "details" redirect_to scheme_location_path(@scheme, @location) else - redirect_to scheme_location_units_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_units_path(@scheme, @location, route: params[:route]) end else render :name, status: :unprocessable_entity @@ -86,9 +82,9 @@ class LocationsController < ApplicationController if @location.valid?(:units) @location.save! if params[:referrer] == "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else - redirect_to scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_type_of_unit_path(@scheme, @location, route: params[:route]) end else render :units, status: :unprocessable_entity @@ -102,9 +98,9 @@ class LocationsController < ApplicationController if @location.valid?(:type_of_unit) @location.save! if params[:referrer] == "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else - redirect_to scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_mobility_standards_path(@scheme, @location, route: params[:route]) end else render :type_of_unit, status: :unprocessable_entity @@ -118,9 +114,9 @@ class LocationsController < ApplicationController if @location.valid?(:mobility_type) @location.save! if params[:referrer] == "check_answers" - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else - redirect_to scheme_location_availability_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_availability_path(@scheme, @location, route: params[:route]) end else render :mobility_standards, status: :unprocessable_entity @@ -138,7 +134,7 @@ class LocationsController < ApplicationController @location.startdate = Time.zone.local(year.to_i, month.to_i, day.to_i) if @location.valid?(:startdate) @location.save! - redirect_to scheme_location_check_answers_path(@scheme, @location, referrer: params[:referrer]) + redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else render :availability, status: :unprocessable_entity end @@ -157,6 +153,8 @@ class LocationsController < ApplicationController def check_answers if params[:location].present? + @location.confirmed = true + @location.save! flash[:notice] = "#{@location.postcode} #{@location.startdate < Time.zone.now ? 'has been' : 'will be'} added to this scheme" redirect_to scheme_locations_path(@scheme) end diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index fd5c1a2c1..fae591445 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, referrer: "new_scheme") + scheme_check_answers_path(@scheme) when "details" if @scheme.arrangement_type_before_type_cast == "D" scheme_primary_client_group_path(@scheme) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 1d4a1a9aa..709bbacd6 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -16,18 +16,6 @@ module CheckAnswersHelper !scheme.confirmed? || editable_attributes.include?(attribute_name) end - def get_location_change_link_href_postcode(scheme, location) - if location.confirmed? - scheme_location_path(scheme_id: scheme.id, id: location.id) - else - edit_scheme_location_path(scheme_id: scheme.id, id: location.id) - end - end - - def get_location_change_link_href_location_admin_district(scheme, location) - scheme_location_edit_local_authority_path(scheme_id: scheme.id, location_id: location.id) - end - def any_questions_have_summary_card_number?(subsection, lettings_log) subsection.applicable_questions(lettings_log).map(&:check_answers_card_number).compact.length.positive? end diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 14d10668f..b775e8ec0 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -56,19 +56,19 @@ module LocationsHelper def location_edit_path(location, page) case page when "postcode" - scheme_location_postcode_path(location.scheme, location, referrer: "check_answers") + scheme_location_postcode_path(location.scheme, location, referrer: "check_answers", route: params[:route]) when "name" - scheme_location_name_path(location.scheme, location, referrer: "check_answers") + scheme_location_name_path(location.scheme, location, referrer: "check_answers", route: params[:route]) when "location_admin_district" - scheme_location_local_authority_path(location.scheme, location, referrer: "check_answers") + scheme_location_local_authority_path(location.scheme, location, referrer: "check_local_authority", route: params[:route]) when "units" - scheme_location_units_path(location.scheme, location, referrer: "check_answers") + scheme_location_units_path(location.scheme, location, referrer: "check_answers", route: params[:route]) when "type_of_unit" - scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers") + scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers", route: params[:route]) when "mobility_standards" - scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers") + scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers", route: params[:route]) when "availability" - scheme_location_availability_path(location.scheme, location, referrer: "check_answers") + scheme_location_availability_path(location.scheme, location, referrer: "check_answers", route: params[:route]) end end diff --git a/app/helpers/tab_nav_helper.rb b/app/helpers/tab_nav_helper.rb index 1d42332f9..3c61c9de0 100644 --- a/app/helpers/tab_nav_helper.rb +++ b/app/helpers/tab_nav_helper.rb @@ -11,17 +11,6 @@ module TabNavHelper [govuk_link_to(link_text, link, method: :patch), "Location #{location.name}"].join("\n") end - def location_cell_location_admin_district(location, link) - la = location.location_admin_district - if location.confirmed? - la - elsif la - govuk_link_to(la, link, method: :patch) - else - govuk_link_to("Select local authority", link, method: :patch) - end - end - def scheme_cell(scheme) link_text = scheme.service_name link = scheme.confirmed? ? scheme : scheme_check_answers_path(scheme) diff --git a/app/views/locations/availability.erb b/app/views/locations/availability.erb index 702ea9258..264c81869 100644 --- a/app/views/locations/availability.erb +++ b/app/views/locations/availability.erb @@ -3,11 +3,11 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer]), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_mobility_standards_path(@scheme, @location, route: params[:route]), ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -22,7 +22,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/locations/check_answers.html.erb b/app/views/locations/check_answers.html.erb index 3356f75af..80bc66b6b 100644 --- a/app/views/locations/check_answers.html.erb +++ b/app/views/locations/check_answers.html.erb @@ -4,9 +4,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: case params[:referrer] - when "new_scheme" - scheme_location_availability_path(@scheme, @location, referrer: params[:referrer]) + href: case params[:route] when "locations" scheme_locations_path(@scheme) else @@ -15,7 +13,7 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_check_answers_path(@scheme, @location)) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_check_answers_path(@scheme, @location, route: params[:route])) do |f| %> <%= render partial: "organisations/headings", locals: { main: "Check your answers", sub: "Add a location to #{@scheme.service_name}" } %>
@@ -35,7 +33,7 @@ details_html(attr) end %> <% end %> - <% row.action(text: "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:name] == "Status" %> + <% row.action(text: attr[:value].blank? || (attr[:attribute] == "availability" && @location.startdate.blank?) ? "Answer" : "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:attribute] == "status" %> <% end %> <% end %> <% end %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index bc436bb18..07f39dfb4 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -52,11 +52,11 @@ <%= table.body do |body| %> <%= body.row do |row| %> <% row.cell(text: location.id) %> - <% row.cell(text: simple_format(location_cell_postcode(location, location.confirmed ? scheme_location_path(@scheme, location) : scheme_location_check_answers_path(@scheme, location, referrer: "locations")), { 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, route: "locations")), { 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) %> - <% row.cell(text: simple_format(location_cell_location_admin_district(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit-local-authority"), wrapper_tag: "div")) %> + <% row.cell(text: location.location_admin_district) %> <% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %> <% end %> <% end %> diff --git a/app/views/locations/local_authority.html.erb b/app/views/locations/local_authority.html.erb index 32e035950..f4ea960aa 100644 --- a/app/views/locations/local_authority.html.erb +++ b/app/views/locations/local_authority.html.erb @@ -3,11 +3,16 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]), + href: case params[:referrer] + when "check_local_authority" + scheme_location_check_answers_path(@scheme, @location, route: params[:route]) + else + scheme_location_postcode_path(@scheme, @location, route: params[:route], referrer: params[:referrer]) + end ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_local_authority_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_local_authority_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -22,9 +27,9 @@ "data-controller": %w[conditional-filter accessible-autocomplete] %>
- <% if params[:referrer] == "check_answers" %> + <% if params[:referrer] == "check_answers" || params[:referrer] == "check_local_authority"%> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/locations/mobility_standards.html.erb b/app/views/locations/mobility_standards.html.erb index 663544c7d..1d536c35b 100644 --- a/app/views/locations/mobility_standards.html.erb +++ b/app/views/locations/mobility_standards.html.erb @@ -3,11 +3,11 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer]), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_type_of_unit_path(@scheme, @location, route: params[:route]), ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -24,7 +24,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/locations/name.html.erb b/app/views/locations/name.html.erb index 6c6ef57e6..ff3bc6131 100644 --- a/app/views/locations/name.html.erb +++ b/app/views/locations/name.html.erb @@ -4,14 +4,16 @@ <%= govuk_back_link( text: "Back", href: if params[:referrer] == "check_answers" - scheme_location_check_answers_path(@scheme, @location) + scheme_location_check_answers_path(@scheme, @location, route: params[:route]) + elsif params[:referrer] == "details" + scheme_location_path(@scheme, @location) else - params[:referrer] == "details" ? scheme_location_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]) + scheme_location_postcode_path(@scheme, @location, route: params[:route]) end, ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -25,7 +27,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% elsif params[:referrer] == "details" %> <%= f.govuk_submit "Save changes" %> <%= govuk_button_link_to "Cancel", scheme_location_path(@scheme, @location), secondary: true %> diff --git a/app/views/locations/postcode.html.erb b/app/views/locations/postcode.html.erb index bdebfd87b..461f91d84 100644 --- a/app/views/locations/postcode.html.erb +++ b/app/views/locations/postcode.html.erb @@ -3,18 +3,15 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: case params[:referrer] - when "check_answers" - scheme_location_check_answers_path(@scheme, @location) - when "new_scheme" - scheme_support_path(@scheme) + href: if params[:referrer] == "check_answers" + scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else scheme_locations_path(@scheme) end ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -29,7 +26,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/locations/type_of_unit.html.erb b/app/views/locations/type_of_unit.html.erb index e437c1374..9d8f3883d 100644 --- a/app/views/locations/type_of_unit.html.erb +++ b/app/views/locations/type_of_unit.html.erb @@ -3,11 +3,11 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_units_path(@scheme, @location, referrer: params[:referrer]), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_units_path(@scheme, @location, route: params[:route]), ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -23,7 +23,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/locations/units.html.erb b/app/views/locations/units.html.erb index 1b2fa6271..7edaf5769 100644 --- a/app/views/locations/units.html.erb +++ b/app/views/locations/units.html.erb @@ -3,11 +3,11 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_name_path(@scheme, @location, referrer: params[:referrer]), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_name_path(@scheme, @location, route: params[:route]), ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location, referrer: params[:referrer])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
<%= f.govuk_error_summary %> @@ -23,7 +23,7 @@
<% if params[:referrer] == "check_answers" %> <%= f.govuk_submit "Save changes" %> - <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %> + <%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> <% else %> <%= f.govuk_submit "Save and continue" %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index 9f87ec566..806b8838a 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -33,53 +33,6 @@ <% end %> <% end %> - <% component.tab(label: "Locations") do %> -

Locations

- <%= govuk_table do |table| %> - <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <%= @scheme.locations.count %> <%= @scheme.locations.count.eql?(1) ? "location" : "locations" %> - <% end %> - <%= table.head do |head| %> - <%= head.row do |row| %> - <% row.cell(header: true, text: "Code", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Postcode", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Units", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Common unit type", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Mobility type", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Local authority", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Available from", html_attributes: { - scope: "col", - }) %> - <% end %> - <% end %> - <% @scheme.locations.each do |location| %> - <%= table.body do |body| %> - <%= body.row do |row| %> - <% row.cell(text: location.id) %> - <% row.cell(text: simple_format(location_cell_postcode(location, get_location_change_link_href_postcode(@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) %> - <% row.cell(text: simple_format(location_cell_location_admin_district(location, get_location_change_link_href_location_admin_district(@scheme, location)), wrapper_tag: "div")) %> - <% row.cell(text: location_availability(location)) %> - <% end %> - <% end %> - <% end %> - <% end %> - <%= govuk_button_link_to "Add a location", new_scheme_location_path(scheme_id: @scheme.id), secondary: true %> - <% end %> <% end %> <%= f.hidden_field :page, value: "check-answers" %> <%= f.hidden_field :confirmed, value: "true" %> diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 8260cf538..85da73c1e 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -258,7 +258,7 @@ RSpec.describe "Schemes scheme Features" do end it "shows the new location form" do - expect(page).to have_content("Add a location to this scheme") + expect(page).to have_content("Add a location to #{scheme.service_name}") end context "when the user completes the new location form" do @@ -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 FooBar" + expect(page).to have_content "Add a location to #{scheme.service_name}" end it "lets me navigate back to support questions" do @@ -817,7 +817,7 @@ RSpec.describe "Schemes scheme Features" do assert_selector "a", text: "Change", count: 1 click_link("Change") - expect(page).to have_content "Location name for #{location.postcode}" + expect(page).to have_content "What is the name of this location?" end it "allows to deactivate a location" do @@ -843,7 +843,7 @@ RSpec.describe "Schemes scheme Features" do it "returns to locations check your answers page and shows the new name" do fill_in "location-name-field", with: "NewName" - click_button "Save and continue" + click_button "Save changes" expect(page).to have_content location.postcode expect(page).to have_content "NewName" expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{location.id}") @@ -909,24 +909,32 @@ RSpec.describe "Schemes scheme Features" do end it "shows the new location form" do - expect(page).to have_content("Add a location to this scheme") + expect(page).to have_content("Add a location to #{scheme.service_name}") end context "when the user completes the new location form" do let(:location_name) { "Area 42" } before do - fill_in "Postcode", with: "NW1L 5DP" - fill_in "Location name (optional)", with: location_name - fill_in "Total number of units at this location", with: 1 + fill_in with: "NW1L 5DP" + click_button "Save and continue" + fill_in with: location_name + click_button "Save and continue" + fill_in with: "Adur" + fill_in with: 1 + click_button "Save and continue" choose "Bungalow" + click_button "Save and continue" choose "location-mobility-type-none-field" - choose "location-add-another-location-no-field" + click_button "Save and continue" + fill_in "Day", with: 2 + fill_in "Month", with: 2 + fill_in "Year", with: 2022 click_button "Save and continue" end it "shows the check answers page location tab" do - expect(page.current_url.split("/").last).to eq("check-answers#locations") + expect(page.current_url.split("/").last).to eq("check-answers") expect(page).to have_content(location_name) end