From 146db3ad4b98c553a76306fe5b11819b96cf8fc0 Mon Sep 17 00:00:00 2001 From: JG Date: Tue, 28 Jun 2022 11:57:54 +0100 Subject: [PATCH] testing confirm secondary group update with YES NO and returning from check answers page --- spec/requests/schemes_controller_spec.rb | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 5954a4f16..1b3f8b39f 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -660,6 +660,56 @@ RSpec.describe SchemesController, type: :request do end end end + + context "when updating confirm secondary client group" do + let(:params) { { scheme: { has_other_client_group: "Yes", page: "confirm-secondary" } } } + + before do + sign_in user + patch "/schemes/#{scheme_to_update.id}", params: + end + + it "renders secondary client group after successful update" do + follow_redirect! + expect(response).to have_http_status(:ok) + expect(page).to have_content("What is the other client group?") + end + + it "updates a scheme with valid params" do + follow_redirect! + expect(scheme_to_update.reload.has_other_client_group).to eq("Yes") + end + + context "when updating from check answers page with the answer YES" do + let(:params) { { scheme: { has_other_client_group: "Yes", page: "confirm-secondary", 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("What is the other client group?") + end + + it "updates a scheme with valid params" do + follow_redirect! + expect(scheme_to_update.reload.has_other_client_group).to eq("Yes") + end + end + + context "when updating from check answers page with the answer NO" do + let(:params) { { scheme: { has_other_client_group: "No", page: "confirm-secondary", 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.has_other_client_group).to eq("No") + end + end + end end end end