Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-11-07 18:19:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-07 18:19:19 +0300
commitd4fcd1794ea9fc10d83cdc75490f76a418e59d52 (patch)
treeb072bfe2c59dc666ddaa28c11e0c04a7971014e0 /spec/models/namespace_spec.rb
parentdfa6eac07553d5a3f254ee904e4298bd666b410f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r--spec/models/namespace_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index a460e47a0e5..590abebb764 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -569,6 +569,48 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do
end
end
end
+
+ describe "#default_branch_protection_settings" do
+ let(:default_branch_protection_defaults) { {} }
+ let(:namespace_setting) { create(:namespace_settings, default_branch_protection_defaults: default_branch_protection_defaults) }
+ let(:namespace) { create(:namespace, namespace_settings: namespace_setting) }
+ let(:group) { create(:group, namespace_settings: namespace_setting) }
+
+ before do
+ stub_application_setting(default_branch_protection_defaults: Gitlab::Access::BranchProtection.protected_against_developer_pushes)
+ end
+
+ context 'for a namespace' do
+ it 'returns the instance level setting' do
+ expected_settings = Gitlab::Access::BranchProtection.protected_against_developer_pushes.deep_stringify_keys
+ settings = namespace.default_branch_protection_settings.to_hash
+
+ expect(settings).to eq(expected_settings)
+ end
+ end
+
+ context 'for a group' do
+ context 'that has not altered the default value' do
+ it 'returns the instance level setting' do
+ expected_settings = Gitlab::Access::BranchProtection.protected_against_developer_pushes.deep_stringify_keys
+ settings = group.default_branch_protection_settings.to_hash
+
+ expect(settings).to eq(expected_settings)
+ end
+ end
+
+ context 'that has altered the default value' do
+ let(:default_branch_protection_defaults) { Gitlab::Access::BranchProtection.protected_fully.deep_stringify_keys }
+
+ it 'returns the group level setting' do
+ expected_settings = default_branch_protection_defaults
+ settings = group.default_branch_protection_settings.to_hash
+
+ expect(settings).to eq(expected_settings)
+ end
+ end
+ end
+ end
end
describe "Respond to" do