summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-28 18:01:09 +0000
committerRémy Coutable <remy@rymai.me>2017-11-28 18:01:09 +0000
commitbecf29e3ab3463a8a1f3c6ed7bbfd7d2dcc49ea0 (patch)
treea56172dc723850b3baf3452a575bb77c461dbe64 /spec/models
parent2081650afc6417daa5933146c0922ff622a958b7 (diff)
parent3c6a4d63636ba41dad0ce63cf536761fc3b5ef64 (diff)
downloadgitlab-ce-becf29e3ab3463a8a1f3c6ed7bbfd7d2dcc49ea0.tar.gz
Merge branch '40530-merge-request-generates-wrong-diff-when-branch-and-tag-have-the-same-name' into 'master'
Resolve "Merge request generates wrong diff when branch and tag have the same name" Closes #40530 See merge request gitlab-org/gitlab-ce!15591
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/merge_request_spec.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 3cf8fc816ff..728028746d8 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -259,7 +259,7 @@ describe MergeRequest do
end
describe '#source_branch_sha' do
- let(:last_branch_commit) { subject.source_project.repository.commit(subject.source_branch) }
+ let(:last_branch_commit) { subject.source_project.repository.commit(Gitlab::Git::BRANCH_REF_PREFIX + subject.source_branch) }
context 'with diffs' do
subject { create(:merge_request, :with_diffs) }
@@ -273,6 +273,21 @@ describe MergeRequest do
it 'returns the sha of the source branch last commit' do
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
end
+
+ context 'when there is a tag name matching the branch name' do
+ let(:tag_name) { subject.source_branch }
+
+ it 'returns the sha of the source branch last commit' do
+ subject.source_project.repository.add_tag(subject.author,
+ tag_name,
+ subject.target_branch_sha,
+ 'Add a tag')
+
+ expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
+
+ subject.source_project.repository.rm_tag(subject.author, tag_name)
+ end
+ end
end
context 'when the merge request is being created' do
@@ -933,7 +948,7 @@ describe MergeRequest do
context 'with a completely different branch' do
before do
- subject.update(target_branch: 'v1.0.0')
+ subject.update(target_branch: 'csv')
end
it_behaves_like 'returning all SHA'
@@ -941,7 +956,7 @@ describe MergeRequest do
context 'with a branch having no difference' do
before do
- subject.update(target_branch: 'v1.1.0')
+ subject.update(target_branch: 'branch-merged')
subject.reload # make sure commits were not cached
end