Commit bcb756cf authored by Luke Duncalfe's avatar Luke Duncalfe

Update ee specs to correctly select MR author

When ce MR https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/26144
was merged in, it caused failures in ee specs
https://gitlab.com/gitlab-org/gitlab-ee/issues/10567.

The fix for these specs is to select an "author" of the MR by first
filtering merge commits from the commit collection. This mirrors the
behaviour of MergeRequest#authors.

Previously, this test passed as MergeRequest#commits would always return
commits that lacked parent_ids, as they are initialized from data
kept in MergeRequestDiffCommit which does not have parent_ids data. This
meant that all MR commits were considered not to be merge commits, even
though in gitaly some did have parent ids.

However, now, CommitCollection#enrich! is called
CommitCollection#without_merge_commits is called (as it is when
MergeRequest#authors is called), so commit data is fetched from gitaly
and now have parent_ids data. This cause the tests to fail, because the
"author" being chosen from the merge request commits was in fact the
user who had committed a merge commit.
parent 4844018b
......@@ -60,7 +60,7 @@ describe ApprovableForRule do
end
context 'when user is committer' do
let(:user) { create(:user, email: merge_request.commits.first.committer_email) }
let(:user) { create(:user, email: merge_request.commits.without_merge_commits.first.committer_email) }
before do
project.add_developer(user)
......@@ -90,7 +90,7 @@ describe ApprovableForRule do
end
it 'returns false when user is a committer' do
user = create(:user, email: merge_request.commits.first.committer_email)
user = create(:user, email: merge_request.commits.without_merge_commits.first.committer_email)
project.add_developer(user)
create(:approver, target: merge_request, user: user)
......
......@@ -79,7 +79,7 @@ describe Approvable do
end
context 'when user is committer' do
let(:user) { create(:user, email: merge_request.commits.first.committer_email) }
let(:user) { create(:user, email: merge_request.commits.without_merge_commits.first.committer_email) }
before do
project.add_developer(user)
......@@ -109,7 +109,7 @@ describe Approvable do
end
it 'returns false when user is a committer' do
user = create(:user, email: merge_request.commits.first.committer_email)
user = create(:user, email: merge_request.commits.without_merge_commits.first.committer_email)
project.add_developer(user)
create(:approver, target: merge_request, user: user)
......
......@@ -85,7 +85,7 @@ describe VisibleApprovableForRule do
end
context 'when committer is approver' do
let(:approver) { create(:user, email: resource.commits.first.committer_email) }
let(:approver) { create(:user, email: resource.commits.without_merge_commits.first.committer_email) }
it_behaves_like 'able to exclude authors'
end
......
......@@ -69,7 +69,7 @@ describe VisibleApprovable do
end
context 'when committer is approver' do
let(:user) { create(:user, email: resource.commits.first.committer_email) }
let(:user) { create(:user, email: resource.commits.without_merge_commits.first.committer_email) }
let!(:committer_approver) { create(:approver, target: project, user: user) }
before do
......
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