summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-11-09 11:12:42 +0000
committerDouwe Maan <douwe@gitlab.com>2015-11-09 11:12:42 +0000
commit03b12ee5502e56b3cc9b14dfa92722f52ce41bce (patch)
treecc43d516cf4999d63011c5a4be501cb2e82cbf51 /spec/services
parent9f055126479000764b488cbb8e91733daaca1c36 (diff)
parent8f2561b193ad39f116655af0789798b45ad906c8 (diff)
downloadgitlab-ce-03b12ee5502e56b3cc9b14dfa92722f52ce41bce.tar.gz
Merge branch 'fix-commits-manual-merge' into 'master'
Fix bug where manually merged branches in a MR would end up with an empty diff This bug manifested in 8.1 with the refactoring of `RefreshService`. Here's what happens: 1. User create a new branch `foo`. 2. User creates a merge request for `foo`. 3. User merges `foo` into `master` by hand. 4. `RefreshService` reloads the merge request. Since `master` is equivalent to `foo`, this results in an empty diff. 5. `RefreshService` then closes the MR. This wasn't an issue when you use the normal "Accept Merge Request" flow because the act of clicking the button closes the merge request, so step 4 never happens. Closes #3314 See merge request !1758
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 227ac995ec2..7ee4488521d 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -62,6 +62,25 @@ describe MergeRequests::RefreshService do
it { expect(@fork_merge_request.notes.last.note).to include('changed to merged') }
end
+ context 'manual merge of source branch' do
+ before do
+ # Merge master -> feature branch
+ author = { email: 'test@gitlab.com', time: Time.now, name: "Me" }
+ commit_options = { message: 'Test message', committer: author, author: author }
+ master_commit = @project.repository.commit('master')
+ @project.repository.merge(@user, master_commit.id, 'feature', commit_options)
+ commit = @project.repository.commit('feature')
+ service.new(@project, @user).execute(@oldrev, commit.id, 'refs/heads/feature')
+ reload_mrs
+ end
+
+ it { expect(@merge_request.notes.last.note).to include('changed to merged') }
+ it { expect(@merge_request).to be_merged }
+ it { expect(@merge_request.diffs.length).to be > 0 }
+ it { expect(@fork_merge_request).to be_merged }
+ it { expect(@fork_merge_request.notes.last.note).to include('changed to merged') }
+ end
+
context 'push to fork repo source branch' do
let(:refresh_service) { service.new(@fork_project, @user) }
before do