diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/models/namespace_setting_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/models/namespace_setting_spec.rb')
-rw-r--r-- | spec/models/namespace_setting_spec.rb | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/spec/models/namespace_setting_spec.rb b/spec/models/namespace_setting_spec.rb index 257d78dfa2c..c6e8d5b129c 100644 --- a/spec/models/namespace_setting_spec.rb +++ b/spec/models/namespace_setting_spec.rb @@ -3,5 +3,71 @@ require 'spec_helper' RSpec.describe NamespaceSetting, type: :model do - it { is_expected.to belong_to(:namespace) } + # Relationships + # + describe "Associations" do + it { is_expected.to belong_to(:namespace) } + end + + describe "validations" do + describe "#default_branch_name_content" do + let_it_be(:group) { create(:group) } + + let(:namespace_settings) { group.namespace_settings } + + shared_examples "doesn't return an error" do + it "doesn't return an error" do + expect(namespace_settings.valid?).to be_truthy + expect(namespace_settings.errors.full_messages).to be_empty + end + end + + context "when not set" do + it_behaves_like "doesn't return an error" + end + + context "when set" do + before do + namespace_settings.default_branch_name = "example_branch_name" + end + + it_behaves_like "doesn't return an error" + end + + context "when an empty string" do + before do + namespace_settings.default_branch_name = '' + end + + it "returns an error" do + expect(namespace_settings.valid?).to be_falsey + expect(namespace_settings.errors.full_messages).not_to be_empty + end + end + end + + describe '#allow_mfa_for_group' do + let(:settings) { group.namespace_settings } + + context 'group is top-level group' do + let(:group) { create(:group) } + + it 'is valid' do + settings.allow_mfa_for_subgroups = false + + expect(settings).to be_valid + end + end + + context 'group is a subgroup' do + let(:group) { create(:group, parent: create(:group)) } + + it 'is invalid' do + settings.allow_mfa_for_subgroups = false + + expect(settings).to be_invalid + end + end + end + end end |