diff options
Diffstat (limited to 'spec/models/application_setting_spec.rb')
-rw-r--r-- | spec/models/application_setting_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 29540507faf..113b07c320b 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -1525,4 +1525,50 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do expect(setting.personal_access_tokens_disabled?).to eq(false) end end + + describe 'email_confirmation_setting prefixes' do + before do + described_class.create_from_defaults + end + + context 'when feature flag `soft_email_confirmation` is not enabled' do + before do + stub_feature_flags(soft_email_confirmation: false) + end + + where(:email_confirmation_setting, :off, :soft, :hard) do + 'off' | true | false | false + 'soft' | false | true | false + 'hard' | false | false | true + end + + with_them do + it 'returns the correct value when prefixed' do + stub_application_setting_enum('email_confirmation_setting', email_confirmation_setting) + + expect(described_class.last.email_confirmation_setting_off?).to be off + expect(described_class.last.email_confirmation_setting_soft?).to be soft + expect(described_class.last.email_confirmation_setting_hard?).to be hard + end + end + + it 'calls super' do + expect(described_class.last.email_confirmation_setting_off?).to be true + expect(described_class.last.email_confirmation_setting_soft?).to be false + expect(described_class.last.email_confirmation_setting_hard?).to be false + end + end + + context 'when feature flag `soft_email_confirmation` is enabled' do + before do + stub_feature_flags(soft_email_confirmation: true) + end + + it 'returns correct value when enum is prefixed' do + expect(described_class.last.email_confirmation_setting_off?).to be false + expect(described_class.last.email_confirmation_setting_soft?).to be true + expect(described_class.last.email_confirmation_setting_hard?).to be false + end + end + end end |