Browse Source

Do not display secondary client group if not given (#2040)

pull/2046/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
86fde672e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/helpers/schemes_helper.rb
  2. 25
      spec/helpers/schemes_helper_spec.rb

4
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)

25
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

Loading…
Cancel
Save