diff --git a/app/services/feature_toggle.rb b/app/services/feature_toggle.rb index 3fcd15a74..30151ad47 100644 --- a/app/services/feature_toggle.rb +++ b/app/services/feature_toggle.rb @@ -39,6 +39,5 @@ class FeatureToggle # if nil this feature will be disabled def self.support_organisation_allow_list return [1] if Rails.env.production? - return [1] if Rails.env.development? end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 495d5ba13..b461b60e5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -540,6 +540,53 @@ RSpec.describe User, type: :model do .to raise_error(ActiveRecord::RecordInvalid, error_message) end end + + describe "#support_user_is_in_correct_organisation" do + let(:organisation) { create(:organisation) } + + context "when the user is not a support user" do + let(:user) { build(:user, :data_coordinator, organisation:) } + + it "is valid regardless of the allow list" do + allow(FeatureToggle).to receive(:support_organisation_allow_list).and_return([999]) + expect(user).to be_valid + end + end + + context "when the user is a support user" do + let(:user) { build(:user, :support, organisation:) } + + context "and the allow list is nil" do + before do + allow(FeatureToggle).to receive(:support_organisation_allow_list).and_return(nil) + end + + it "is valid" do + expect(user).to be_valid + end + end + + context "and the organisation is in the allow list" do + before do + allow(FeatureToggle).to receive(:support_organisation_allow_list).and_return([organisation.id]) + end + + it "is valid" do + expect(user).to be_valid + end + end + + context "and the organisation is not in the allow list" do + before do + allow(FeatureToggle).to receive(:support_organisation_allow_list).and_return([organisation.id + 1]) + end + + it "is not valid" do + expect(user).not_to be_valid + end + end + end + end end describe "delete" do