diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 06:08:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 06:08:57 +0300 |
commit | 852f4a85dd199751e4652748461163de85ecda53 (patch) | |
tree | b4160aa19c23582b5ab5ac02f9860b5498007c43 /spec/models/application_setting_spec.rb | |
parent | 82cd20acf9f4cceecf222abe718a9e23cef55687 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/application_setting_spec.rb')
-rw-r--r-- | spec/models/application_setting_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index bbd50f1c0ef..934e26a74fe 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -633,5 +633,56 @@ describe ApplicationSetting do end end + describe 'email_restrictions' do + context 'when email restrictions are enabled' do + before do + subject.email_restrictions_enabled = true + end + + it 'allows empty email restrictions' do + subject.email_restrictions = '' + + expect(subject).to be_valid + end + + it 'accepts valid email restrictions regex' do + subject.email_restrictions = '\+' + + expect(subject).to be_valid + end + + it 'does not accept invalid email restrictions regex' do + subject.email_restrictions = '+' + + expect(subject).not_to be_valid + end + + it 'sets an error when regex is not valid' do + subject.email_restrictions = '+' + + expect(subject).not_to be_valid + expect(subject.errors.messages[:email_restrictions].first).to eq(_('is not a valid regular expression')) + end + end + + context 'when email restrictions are disabled' do + before do + subject.email_restrictions_enabled = false + end + + it 'allows empty email restrictions' do + subject.email_restrictions = '' + + expect(subject).to be_valid + end + + it 'invalid regex is not valid' do + subject.email_restrictions = '+' + + expect(subject).not_to be_valid + end + end + end + it_behaves_like 'application settings examples' end |