Commit 2f7ae046 authored by manojmj's avatar manojmj

Address code review comments

This change addresses code review
comments
parent 2b3c511c
......@@ -290,12 +290,10 @@ describe GroupsController do
end
context 'for users who do not have the ability to create a group with `default_branch_protection`' do
before do
it 'does not create the group with the specified branch protection level' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :create_group_with_default_branch_protection) { false }
end
it 'does not create the group with the specified branch protection level' do
subject
expect(response).to have_gitlab_http_status(:found)
......@@ -471,12 +469,10 @@ describe GroupsController do
end
context 'for users who do not have the ability to update default_branch_protection' do
before do
it 'does not update the attribute' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :update_default_branch_protection, group) { false }
end
it 'does not update the attribute' do
subject
expect(response).to have_gitlab_http_status(:found)
......
......@@ -657,12 +657,10 @@ describe API::Groups do
end
context 'for users who does not have the ability to update default_branch_protection`' do
before do
it 'does not update the attribute' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user1, :update_default_branch_protection, group1) { false }
end
it 'does not update the attribute' do
subject
expect(response).to have_gitlab_http_status(:ok)
......@@ -1155,12 +1153,10 @@ describe API::Groups do
end
context 'for users who do not have the ability to create a group with `default_branch_protection`' do
before do
it 'does not create the group with the specified branch protection level' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user3, :create_group_with_default_branch_protection) { false }
end
it 'does not create the group with the specified branch protection level' do
subject
expect(response).to have_gitlab_http_status(:created)
......
......@@ -29,9 +29,6 @@ describe Groups::CreateService, '#execute' do
let(:service) { described_class.new(user, params) }
let(:created_group) { service.execute }
before do
end
context 'for users who have the ability to create a group with `default_branch_protection`' do
it 'creates group with the specified branch protection level' do
expect(created_group.default_branch_protection).to eq(Gitlab::Access::PROTECTION_NONE)
......@@ -39,12 +36,10 @@ describe Groups::CreateService, '#execute' do
end
context 'for users who do not have the ability to create a group with `default_branch_protection`' do
before do
it 'does not create the group with the specified branch protection level' do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :create_group_with_default_branch_protection) { false }
end
it 'does not create the group with the specified branch protection level' do
expect(created_group.default_branch_protection).not_to eq(Gitlab::Access::PROTECTION_NONE)
end
end
......
......@@ -154,11 +154,9 @@ describe Groups::UpdateService do
end
context 'for users who have the ability to update default_branch_protection' do
before do
it 'updates the attribute' do
internal_group.add_owner(user)
end
it 'updates the attribute' do
expect { service.execute }.to change { internal_group.default_branch_protection }.to(Gitlab::Access::PROTECTION_NONE)
end
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