Commit 9ab0af3b authored by Gosia Ksionek's avatar Gosia Ksionek Committed by Imre Farkas

Update groups factory and specs for consistency

parent 568940df
......@@ -24,9 +24,6 @@ RSpec.describe ForkTargetsFinder do
context 'when project root group prohibits outer forks' do
context 'when it is configured on saml level' do
before do
create(:namespace_settings, namespace: project_group, prevent_forking_outside_group: false)
end
let(:project_group) do
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: true).group
end
......@@ -57,7 +54,7 @@ RSpec.describe ForkTargetsFinder do
context 'when project root prohibits outer forks' do
before do
create(:namespace_settings, namespace: project_group, prevent_forking_outside_group: true)
project_group.namespace_settings.update!(prevent_forking_outside_group: true)
end
it 'returns namespaces with the same root group as project one only' do
......@@ -67,10 +64,6 @@ RSpec.describe ForkTargetsFinder do
end
context 'when project root does not prohibit outer forks' do
before do
create(:namespace_settings, namespace: project_group, prevent_forking_outside_group: false)
end
it 'returns outer namespaces as well as inner' do
expect(fork_targets).to be_a(ActiveRecord::Relation)
expect(fork_targets).to match_array([outer_group, inner_subgroup, user.namespace])
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe NamespaceSetting do
let(:group) { create(:group) }
let(:setting) { group.namespace_settings }
describe '#prevent_forking_outside_group?' do
context 'with feature available' do
......@@ -12,7 +13,9 @@ RSpec.describe NamespaceSetting do
end
context 'group with no associated saml provider' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: true) }
before do
setting.update!(prevent_forking_outside_group: true)
end
it 'returns namespace setting' do
expect(setting.prevent_forking_outside_group?).to eq(true)
......@@ -25,9 +28,8 @@ RSpec.describe NamespaceSetting do
end
context 'when it is configured to true on saml level' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: true) }
before do
setting.update!(prevent_forking_outside_group: true)
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: true, group: group)
end
......@@ -37,8 +39,6 @@ RSpec.describe NamespaceSetting do
end
context 'when it is configured to false on saml level' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: false) }
before do
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: false, group: group)
end
......@@ -48,7 +48,9 @@ RSpec.describe NamespaceSetting do
end
context 'when setting is configured on namespace level' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: true) }
before do
setting.update!(prevent_forking_outside_group: true)
end
it 'returns namespace setting' do
expect(setting.prevent_forking_outside_group?).to eq(true)
......@@ -59,7 +61,9 @@ RSpec.describe NamespaceSetting do
end
context 'without feature available' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: true) }
before do
setting.update!(prevent_forking_outside_group: true)
end
it 'returns false' do
expect(setting.prevent_forking_outside_group?).to be_falsey
......@@ -71,8 +75,6 @@ RSpec.describe NamespaceSetting do
end
context 'when it is configured to true on saml level' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: false) }
before do
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: true, group: group)
end
......@@ -83,8 +85,6 @@ RSpec.describe NamespaceSetting do
end
context 'when it is configured to false on saml level' do
let(:setting) { create(:namespace_settings, namespace: group, prevent_forking_outside_group: false) }
before do
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: false, group: group)
end
......
......@@ -9,10 +9,6 @@ RSpec.describe EE::NamespaceSettings::UpdateService do
subject { NamespaceSettings::UpdateService.new(user, group, params).execute }
describe '#execute' do
before do
create(:namespace_settings, namespace: group, prevent_forking_outside_group: false)
end
context 'as a normal user' do
let(:params) { { prevent_forking_outside_group: true } }
......
......@@ -14,6 +14,8 @@ FactoryBot.define do
# https://gitlab.com/gitlab-org/gitlab-foss/issues/43292
raise "Don't set owner for groups, use `group.add_owner(user)` instead"
end
create(:namespace_settings, namespace: group)
end
trait :public do
......
......@@ -11,6 +11,10 @@ RSpec.describe NamespaceSettings::UpdateService do
describe "#execute" do
context "group has no namespace_settings" do
before do
group.namespace_settings.destroy!
end
it "builds out a new namespace_settings record" do
expect do
service.execute
......@@ -20,8 +24,6 @@ RSpec.describe NamespaceSettings::UpdateService do
context "group has a namespace_settings" do
before do
create(:namespace_settings, namespace: group)
service.execute
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment