diff --git a/app/helpers/role_organisations_helper.rb b/app/helpers/role_organisations_helper.rb index 8dae66901..152d77cc6 100644 --- a/app/helpers/role_organisations_helper.rb +++ b/app/helpers/role_organisations_helper.rb @@ -1,6 +1,6 @@ module RoleOrganisationsHelper def options_for_organisation_select(current_user) - organisations = Pundit.policy_scope(current_user, Organisation).order(:name) + organisations = Pundit.policy_scope(current_user, Organisation).order(:name).where(closed: false) organisations.map do |organisation| { text: organisation.name_with_abbreviation, diff --git a/test/helpers/role_organisations_helper_test.rb b/test/helpers/role_organisations_helper_test.rb index 74528585a..41753c4b5 100644 --- a/test/helpers/role_organisations_helper_test.rb +++ b/test/helpers/role_organisations_helper_test.rb @@ -5,6 +5,7 @@ class RoleOrganisationsHelperTest < ActionView::TestCase setup do @user_organisation = create(:organisation, name: "User Organisation", abbreviation: "UO") @other_organisation = create(:organisation, name: "Other Organisation") + @closed_organisation = create(:organisation, name: "Closed Organisation", closed: true) @user = create(:admin_user, organisation: @user_organisation) end @@ -34,5 +35,11 @@ class RoleOrganisationsHelperTest < ActionView::TestCase options.map { |o| o[:text] }, ) end + + should "not include closed organisations" do + closed_organisation_option = options_for_organisation_select(@user).detect { |o| o[:value] == @closed_organisation.id } + + assert_not closed_organisation_option + end end end