From 9c7c964783df48f63e13e9b387b507fc3bf78463 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 3 Aug 2022 16:22:48 +0100 Subject: [PATCH] Filter out the primary client group option from secondary client group question (#809) Co-authored-by: Sam Collard Co-authored-by: Sam Collard --- app/views/schemes/secondary_client_group.html.erb | 2 +- spec/features/schemes_helpers.rb | 2 +- spec/requests/schemes_controller_spec.rb | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/schemes/secondary_client_group.html.erb b/app/views/schemes/secondary_client_group.html.erb index d229883ba..4f48dab00 100644 --- a/app/views/schemes/secondary_client_group.html.erb +++ b/app/views/schemes/secondary_client_group.html.erb @@ -14,7 +14,7 @@ <%= render partial: "organisations/headings", locals: { main: "What is the other client group?", sub: @scheme.service_name } %> - <% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key) } %> + <% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing", @scheme.primary_client_group).map { |key, _| OpenStruct.new(id: key, name: key) } %> <%= f.govuk_collection_radio_buttons :secondary_client_group, secondary_client_group_selection, :id, diff --git a/spec/features/schemes_helpers.rb b/spec/features/schemes_helpers.rb index d1a4db2dc..fdbec0c3a 100644 --- a/spec/features/schemes_helpers.rb +++ b/spec/features/schemes_helpers.rb @@ -44,7 +44,7 @@ module SchemesHelpers end def fill_in_and_save_secondary_client_group - choose "Homeless families with support needs" + choose "Offenders and people at risk of offending" click_button "Save and continue" end diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index ce6805f35..3ccc9e461 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -1334,7 +1334,7 @@ RSpec.describe SchemesController, type: :request do context "when signed in as a support user" do let(:user) { FactoryBot.create(:user, :support) } - let!(:scheme) { FactoryBot.create(:scheme) } + let!(:scheme) { FactoryBot.create(:scheme, primary_client_group: Scheme::PRIMARY_CLIENT_GROUP[:"Homeless families with support needs"]) } before do allow(user).to receive(:need_two_factor_authentication?).and_return(false) @@ -1346,6 +1346,11 @@ RSpec.describe SchemesController, type: :request do expect(response).to have_http_status(:ok) expect(page).to have_content("What is the other client group?") end + + it "does not show the primary client group as an option" do + expect(scheme.primary_client_group).not_to be_nil + expect(page).not_to have_content("Homeless families with support needs") + end end end