diff --git a/app/views/batch_invitations/new.html.erb b/app/views/batch_invitations/new.html.erb index 80224afd6..19fcab1f0 100644 --- a/app/views/batch_invitations/new.html.erb +++ b/app/views/batch_invitations/new.html.erb @@ -73,7 +73,7 @@ id: "batch_invitation_organisation_id", name: "batch_invitation[organisation_id]", label: "Organisation", - options: policy_scope(Organisation).map { |organisation| { text: organisation.name_with_abbreviation, value: organisation.id } } + options: policy_scope(Organisation).not_closed.order(:name).map { |organisation| { text: organisation.name_with_abbreviation, value: organisation.id } } } %> <% end %> diff --git a/test/controllers/batch_invitations_controller_test.rb b/test/controllers/batch_invitations_controller_test.rb index 9f043554f..05b0850f6 100644 --- a/test/controllers/batch_invitations_controller_test.rb +++ b/test/controllers/batch_invitations_controller_test.rb @@ -25,6 +25,14 @@ def users_csv(filename = "users.csv") assert_select "#batch_invitation_organisation_id option", organisation.name end + + should "exclude closed organisations from select" do + create(:organisation) + create(:organisation, closed: true) + get :new + + assert_select "#batch_invitation_organisation_id option", 1 + end end context "POST create" do