Browse Source

feat: add new back behaviour for new scheme path and tests wip

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
76a4a05a69
  1. 8
      app/controllers/locations_controller.rb
  2. 2
      app/controllers/schemes_controller.rb
  3. 2
      app/views/locations/index.html.erb
  4. 9
      app/views/locations/postcode.html.erb
  5. 2
      spec/features/schemes_spec.rb

8
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

2
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)

2
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("<span>#{location.type_of_unit}</span>")) %>
<% row.cell(text: location.mobility_type) %>

9
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 %>

2
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

Loading…
Cancel
Save