From 86fde672e38dd79e796523a803c7c4289708f69a Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:01:01 +0000 Subject: [PATCH] Do not display secondary client group if not given (#2040) --- app/helpers/schemes_helper.rb | 4 ++-- spec/helpers/schemes_helper_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb index 6b069fbbb..aea892a18 100644 --- a/app/helpers/schemes_helper.rb +++ b/app/helpers/schemes_helper.rb @@ -11,11 +11,11 @@ module SchemesHelper { name: "Support services provided by", value: scheme.arrangement_type }, { name: "Primary client group", value: scheme.primary_client_group }, { name: "Has another client group", value: scheme.has_other_client_group }, - { name: "Secondary client group", value: scheme.secondary_client_group }, + scheme.has_other_client_group == "Yes" ? { name: "Secondary client group", value: scheme.secondary_client_group } : nil, { name: "Level of support given", value: scheme.support_type }, { name: "Intended length of stay", value: scheme.intended_stay }, { name: "Availability", value: scheme_availability(scheme) }, - ] + ].compact end def scheme_availability(scheme) diff --git a/spec/helpers/schemes_helper_spec.rb b/spec/helpers/schemes_helper_spec.rb index 5aa825e79..ab4b8da5b 100644 --- a/spec/helpers/schemes_helper_spec.rb +++ b/spec/helpers/schemes_helper_spec.rb @@ -266,6 +266,31 @@ RSpec.describe SchemesHelper do end end end + + context "when scheme has no secondary client group" do + before do + scheme.update!(has_other_client_group: 0) + end + + it "returns correct display attributes" do + attributes = [ + { name: "Scheme code", value: "S#{scheme.id}" }, + { name: "Name", value: "Test service_name", edit: true }, + { name: "Status", value: status_tag(:incomplete) }, + { name: "Confidential information", value: "No", edit: true }, + { name: "Type of scheme", value: "Housing for older people" }, + { name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, + { name: "Housing stock owned by", value: "Acme LTD Owning", edit: true }, + { name: "Support services provided by", value: "A registered charity or voluntary organisation" }, + { name: "Primary client group", value: "Rough sleepers" }, + { name: "Has another client group", value: "No" }, + { name: "Level of support given", value: "High level" }, + { name: "Intended length of stay", value: "Permanent" }, + { name: "Availability", value: "Active from 1 April 2021" }, + ] + expect(display_scheme_attributes(scheme)).to eq(attributes) + end + end end describe "edit_scheme_text" do