Commit 63352b7e authored by Alessio Caiazza's avatar Alessio Caiazza

Revert "Merge branch...

Revert "Merge branch '216345-add-project-group-to-group-list-when-specified-as-owner' into 'master'"

This reverts commit c6c95d49, reversing
changes made to 59e842e5.
parent 1794697f
......@@ -23,15 +23,7 @@ module Gitlab
return Group.none if extractor.names.empty?
groups = project.invited_groups.where_full_path_in(extractor.names)
group_list = groups.with_route.with_users.to_a
if extractor.names.include?(project.group&.full_path)
project.group.users.load
group_list << project.group
end
group_list
groups.with_route.with_users
end
end
end
......
......@@ -39,8 +39,6 @@ describe Gitlab::Checks::DiffCheck do
allow(project.repository).to receive(:code_owners_blob)
.with(ref: codeowner_lookup_ref)
.and_return(codeowner_blob)
stub_feature_flags(sectional_codeowners: false)
end
context 'the MR contains a renamed file matching a file path' do
......@@ -58,6 +56,10 @@ describe Gitlab::Checks::DiffCheck do
end
context 'and the user is not listed as a codeowner' do
before do
stub_feature_flags(sectional_codeowners: false)
end
it "returns an error message" do
expect { diff_check.validate! }.to raise_error do |error|
expect(error).to be_a(Gitlab::GitAccess::ForbiddenError)
......@@ -82,14 +84,14 @@ describe Gitlab::Checks::DiffCheck do
subject.send(:validate_code_owners).call(["docs/CODEOWNERS", "README"])
end
shared_examples_for "returns an error message" do
it "returns the expected error message" do
expect(validation_result).to include("Pushes to protected branches")
context "and the user is not listed as a code owner" do
before do
stub_feature_flags(sectional_codeowners: false)
end
end
context "and the user is not listed as a code owner" do
it_behaves_like "returns an error message"
it "returns an error message" do
expect(validation_result).to include("Pushes to protected branches")
end
end
context "and the user is listed as a code owner" do
......@@ -101,32 +103,6 @@ describe Gitlab::Checks::DiffCheck do
expect(validation_result).to be_nil
end
end
context "when the codeowner entity is a group" do
let(:group_a) { create(:group) }
let(:project) { create(:project, :repository, namespace: group_a) }
let(:codeowner_content) do
<<~CODEOWNERS
*.rb @#{code_owner.username}
docs/CODEOWNERS @#{group_a.name}
*.js.coffee @#{group_a.name}
CODEOWNERS
end
context "and the user is part of the codeowning-group" do
before do
group_a.add_developer(user)
end
it "returns nil" do
expect(validation_result).to be_nil
end
end
context "and the user is not part of the codeowning-group" do
it_behaves_like "returns an error message"
end
end
end
context "the MR doesn't contain a matching file path" do
......
......@@ -51,18 +51,7 @@ describe Gitlab::CodeOwners::GroupsLoader do
group = create(:group, path: "GROUP-1")
create(:group, path: "GROUP-2")
project.invited_groups << group
load_groups
expect(entry).to have_received(:add_matching_groups_from).with([group])
end
end
context "input matches project.group" do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, namespace: group) }
let(:text) { "@#{project.group.name}" }
it "returns the project's group" do
load_groups
expect(entry).to have_received(:add_matching_groups_from).with([group])
......
......@@ -71,7 +71,7 @@ describe Gitlab::CodeOwners::Loader do
expect(loader.entries).to contain_exactly(expected_entry, other_entry)
end
it 'only performs 4 queries for users and groups' do
it 'only performs 3 query for users and groups' do
test_group = create(:group, path: 'test-group')
test_group.add_developer(create(:user))
......@@ -80,12 +80,9 @@ describe Gitlab::CodeOwners::Loader do
project.invited_groups << [test_group, another_group]
# - 1 query for users
# - 1 for the emails to later divide them across the entries
# - 1 for groups with joined routes and users
# - 1 for loading the users for the parent group
#
expect { loader.entries }.not_to exceed_query_limit(4)
# One query for users, one for the emails to later divide them across the entries
# one for groups with joined routes and users
expect { loader.entries }.not_to exceed_query_limit(3)
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