From 8024b2126e1786652a493ea29727df943044bba3 Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 30 Jun 2022 16:02:39 +0100 Subject: [PATCH] testing returning back to create page if create another location is selected --- spec/requests/locations_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index 34eb42096..c6e7ef969 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -103,6 +103,23 @@ RSpec.describe LocationsController, type: :request do expect(Location.last.type_of_unit).to eq("Bungalow") expect(Location.last.wheelchair_adaptation).to eq("No") end + + context "when do you want to add another location is selected as yes" do + it "creates a new location for scheme with valid params and redirects to correct page" do + expect { post "/schemes/#{scheme.id}/location/create", params: }.to change(Location, :count).by(1) + expect(response).to have_http_status(:ok) + expect(page).to have_content("Add a location to this scheme") + end + + it "creates a new location for scheme with valid params" do + + expect(Location.last.scheme.organisation_id).to eq(user.organisation_id) + expect(Location.last.name).to eq("Test") + expect(Location.last.total_units).to eq(5) + expect(Location.last.type_of_unit).to eq("Bungalow") + expect(Location.last.wheelchair_adaptation).to eq("No") + end + end end end end