Browse Source

Update routing to go back to location page (#988)

pull/994/head v0.2.20
kosiakkatrina 2 years ago committed by GitHub
parent
commit
aa041784dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/controllers/locations_controller.rb
  2. 2
      app/helpers/check_answers_helper.rb
  3. 4
      spec/features/schemes_spec.rb
  4. 4
      spec/requests/locations_controller_spec.rb

6
app/controllers/locations_controller.rb

@ -98,7 +98,11 @@ class LocationsController < ApplicationController
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
end end
when "edit-name" when "edit-name"
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) if @scheme.locations.count == @scheme.locations.active.count
redirect_to(scheme_location_path(@scheme, @location))
else
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
end
when "edit-local-authority" when "edit-local-authority"
if params[:add_another_location] == "Yes" if params[:add_another_location] == "Yes"
redirect_to(new_scheme_location_path(@location.scheme)) redirect_to(new_scheme_location_path(@location.scheme))

2
app/helpers/check_answers_helper.rb

@ -18,7 +18,7 @@ module CheckAnswersHelper
def get_location_change_link_href_postcode(scheme, location) def get_location_change_link_href_postcode(scheme, location)
if location.confirmed? if location.confirmed?
scheme_location_edit_name_path(scheme_id: scheme.id, location_id: location.id) scheme_location_path(scheme_id: scheme.id, id: location.id)
else else
edit_scheme_location_path(scheme_id: scheme.id, id: location.id) edit_scheme_location_path(scheme_id: scheme.id, id: location.id)
end end

4
spec/features/schemes_spec.rb

@ -801,9 +801,9 @@ RSpec.describe "Schemes scheme Features" do
it "returns to locations check your answers page and shows the new name" do it "returns to locations check your answers page and shows the new name" do
fill_in "location-name-field", with: "NewName" fill_in "location-name-field", with: "NewName"
click_button "Save and continue" click_button "Save and continue"
expect(page).to have_content location.id expect(page).to have_content location.postcode
expect(page).to have_content "NewName" expect(page).to have_content "NewName"
expect(page.current_url.split("/").last).to eq("check-answers#locations") expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{location.id}")
end end
context "when I press the back button" do context "when I press the back button" do

4
spec/requests/locations_controller_spec.rb

@ -597,7 +597,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("Locations") expect(page).to have_content("Test")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do
@ -736,7 +736,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("Locations") expect(page).to have_content("Test")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do

Loading…
Cancel
Save