From 2c97cd04e68a064b982c19bc08d1f78bf0c69a7a Mon Sep 17 00:00:00 2001 From: JG Date: Tue, 28 Jun 2022 12:04:17 +0100 Subject: [PATCH] testing updating secondary client group update and returning from check answers page --- spec/requests/schemes_controller_spec.rb | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 1b3f8b39f..7d7654fbe 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -710,6 +710,41 @@ RSpec.describe SchemesController, type: :request do end end end + + context "when updating secondary client group" do + let(:params) { { scheme: { secondary_client_group: "Homeless families with support needs", page: "secondary-client-group" } } } + + before do + sign_in user + patch "/schemes/#{scheme_to_update.id}", params: + end + + it "renders confirm secondary group after successful update" do + follow_redirect! + expect(response).to have_http_status(:ok) + expect(page).to have_content("What support does this scheme provide?") + end + + it "updates a scheme with valid params" do + follow_redirect! + expect(scheme_to_update.reload.secondary_client_group).to eq("Homeless families with support needs") + end + + context "when updating from check answers page" do + let(:params) { { scheme: { secondary_client_group: "Homeless families with support needs", page: "secondary-client-group", check_answers: "true" } } } + + 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") + end + + it "updates a scheme with valid params" do + follow_redirect! + expect(scheme_to_update.reload.secondary_client_group).to eq("Homeless families with support needs") + end + end + end end end end