From 32743afd4032613ac273d2f25a6ca10ae61e6cad Mon Sep 17 00:00:00 2001 From: JG Date: Mon, 27 Jun 2022 11:30:40 +0100 Subject: [PATCH] added missing test for support questions and nested check answers under correct context --- spec/features/schemes_spec.rb | 145 ++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index d0f4a4423..462d661a8 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -220,6 +220,7 @@ RSpec.describe "Schemes scheme Features" do context "when creating a new scheme" do before do + Scheme.destroy_all click_link "Schemes", href: "/schemes" end @@ -289,97 +290,105 @@ RSpec.describe "Schemes scheme Features" do it "lets me select level of support" do expect(page).to have_content "What support does this scheme provide?" end - end - end - end - end - end - context "when changing answers" do - let!(:scheme) { FactoryBot.create(:scheme) } + context "when I select the support answers" do + before do + choose "Floating support" + choose "Very short stay" + click_button "Save and continue" + end - before do - visit "/schemes/#{scheme.id}/check-answers" - end + it "lets me check my answers" do + expect(page).to have_content "Check your changes before updating this scheme" + end - it "displays change links" do - assert_selector "a", text: "Change", count: 12 - end + context "when changing answers" do + let!(:scheme) { Scheme.first } - it "allows changing details questions" do - click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first) - expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true") + it "displays change links" do + assert_selector "a", text: "Change", count: 12 + end - fill_in "Scheme name", with: "Example" - choose "Direct access hostel" - choose "Yes – registered care home providing nursing care" - click_button "Save and continue" + it "allows changing details questions" do + click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first) + expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "Example" - expect(page).to have_content "Yes – registered care home providing nursing care" - end + fill_in "Scheme name", with: "Example" + choose "Direct access hostel" + choose "Yes – registered care home providing nursing care" + click_button "Save and continue" - it "allows changing primary-client-group question" do - click_link("Change", href: "/schemes/#{scheme.id}/primary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "Example" + expect(page).to have_content "Yes – registered care home providing nursing care" + end - choose "Older people with support needs" - click_button "Save and continue" + it "allows changing primary-client-group question" do + click_link("Change", href: "/schemes/#{scheme.id}/primary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "Older people with support needs" - end + choose "Older people with support needs" + click_button "Save and continue" - it "allows changing secondary-client-group question" do - click_link("Change", href: "/schemes/#{scheme.id}/secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "Older people with support needs" + end - choose "People at risk of domestic violence" - click_button "Save and continue" + it "allows changing secondary-client-group question" do + click_link("Change", href: "/schemes/#{scheme.id}/secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "People at risk of domestic violence" - end + choose "People at risk of domestic violence" + click_button "Save and continue" - it "allows changing confirm-secondary-client-group question to yes" do - click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "People at risk of domestic violence" + end - choose "Yes" - click_button "Save and continue" + it "allows changing confirm-secondary-client-group question to yes" do + click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true") + choose "Yes" + click_button "Save and continue" - choose "People at risk of domestic violence" - click_button "Save and continue" + expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "People at risk of domestic violence" - end + choose "People at risk of domestic violence" + click_button "Save and continue" - it "allows changing confirm-secondary-client-group question to no" do - click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "People at risk of domestic violence" + end - choose "No" - click_button "Save and continue" + it "allows changing confirm-secondary-client-group question to no" do + click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") + expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true") - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "None" - end + choose "No" + click_button "Save and continue" + + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "None" + end - it "allows changing support question to no" do - click_link("Change", href: "/schemes/#{scheme.id}/support?check_answers=true", match: :first) - expect(page).to have_current_path("/schemes/#{scheme.id}/support?check_answers=true") + it "allows changing support questions" do + click_link("Change", href: "/schemes/#{scheme.id}/support?check_answers=true", match: :first) + expect(page).to have_current_path("/schemes/#{scheme.id}/support?check_answers=true") - choose "Resettlement support" - choose "Medium stay" - click_button "Save and continue" + choose "Resettlement support" + choose "Medium stay" + click_button "Save and continue" - expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") - expect(page).to have_content "Resettlement support" - expect(page).to have_content "Medium stay" + expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers") + expect(page).to have_content "Resettlement support" + expect(page).to have_content "Medium stay" + end + end + end + end + end + end end end end