From 2cbb02e8bdc6e4a1d8609c4370ba67d6e00d6c2f Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 25 Mar 2025 13:07:51 +0000 Subject: [PATCH] Add tests to helper --- spec/helpers/organisations_helper_spec.rb | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/helpers/organisations_helper_spec.rb b/spec/helpers/organisations_helper_spec.rb index ebdf73c67..46af25be4 100644 --- a/spec/helpers/organisations_helper_spec.rb +++ b/spec/helpers/organisations_helper_spec.rb @@ -80,4 +80,36 @@ RSpec.describe OrganisationsHelper do end end end + + describe "#group_organisation_options_name" do + let(:older_org) { create(:organisation, group_member: true, group_member_id: 123, group: 9) } + let(:org) { create(:organisation, name: "Org1", group_member: true, group_member_id: older_org.id) } + + it "returns the organisation name with group text" do + allow(org).to receive(:oldest_group_member).and_return(older_org) + name = helper.group_organisation_options_name(org) + expect(name).to eq("Org1 (GROUP9)") + end + end + + describe "#profit_status_options" do + it "returns a list of profit statuses with a null option" do + options = helper.profit_status_options + expect(options.map(&:name)).to include("Select an option") + end + + context "when provider type is LA" do + it "returns only the local authority option" do + options = helper.profit_status_options("LA") + expect(options.map(&:id)).to eq(["", :local_authority]) + end + end + + context "when provider type is PRP" do + it "excludes the local authority option" do + options = helper.profit_status_options("PRP") + expect(options.map(&:id)).not_to include(:local_authority) + end + end + end end