diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index 78fff8674..a35028d64 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -1,6 +1,6 @@ <% content_for :title, "Check your answers before creating this scheme" %> -<%= render partial: "organisations/headings", locals: { main: "Check your changes before updating this scheme", sub: @scheme.service_name } %> +<%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %> <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <% component.tab(label: "Scheme") do %> diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 2141f59f9..c793c617b 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -389,7 +389,7 @@ RSpec.describe "Schemes scheme Features" do end it "lets me check my answers" do - expect(page).to have_content "Check your changes before updating this scheme" + expect(page).to have_content "Check your changes before creating this scheme" end context "and I select to create a scheme" do @@ -412,7 +412,7 @@ RSpec.describe "Schemes scheme Features" do end # it "lets me check my answers" do - # expect(page).to have_content "Check your changes before updating this scheme" + # expect(page).to have_content "Check your changes before creating this scheme" # end end end diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index 3ba53c3e4..34eb42096 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -77,5 +77,32 @@ RSpec.describe LocationsController, type: :request do expect(response).to have_http_status(:unauthorized) end end + + context "when signed in as a data coordinator" do + let(:user) { FactoryBot.create(:user, :data_coordinator) } + let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } + let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No" } } } + + before do + sign_in user + post "/schemes/#{scheme.id}/location/create", params: params + end + + 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) + follow_redirect! + expect(response).to have_http_status(:ok) + expect(page).to have_content("Check your answers before creating 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 diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index e456dc438..2c1eb90ce 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -662,7 +662,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -707,7 +707,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -737,7 +737,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -768,7 +768,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -802,7 +802,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -846,7 +846,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -891,7 +891,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -921,7 +921,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -937,7 +937,7 @@ RSpec.describe SchemesController, type: :request do it "renders confirm secondary group after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -952,7 +952,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -997,7 +997,7 @@ RSpec.describe SchemesController, type: :request do it "renders check answers page after successful update" do follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end it "updates a scheme with valid params" do @@ -1310,7 +1310,7 @@ RSpec.describe SchemesController, type: :request do it "returns a template for a support" do expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end context "when attempting to access check-answers scheme page for another organisation" do @@ -1337,7 +1337,7 @@ RSpec.describe SchemesController, type: :request do it "returns a template for a support" do expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before updating this scheme") + expect(page).to have_content("Check your changes before creating this scheme") end end end