diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-11-09 14:55:45 -0200 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-11-10 12:01:09 -0200 |
commit | bddbb90fd985df50d4b17d0728ef5fa90bf64af7 (patch) | |
tree | 066c1bf6adca984b1a47800d7a5ad78d617ca2ac /spec | |
parent | 65faebb95556809c5858347f1c24422505056827 (diff) | |
download | gitlab-ce-bddbb90fd985df50d4b17d0728ef5fa90bf64af7.tar.gz |
Prevent fast forward merge when rebase is requiredissue_39773_be
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/merge_requests/merge_service_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index ac196e92601..f86f1ac2443 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -248,6 +248,28 @@ describe MergeRequests::MergeService do expect(merge_request.merge_error).to include(error_message) expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message)) end + + context "when fast-forward merge is not allowed" do + before do + allow_any_instance_of(Repository).to receive(:ancestor?).and_return(nil) + end + + %w(semi-linear ff).each do |merge_method| + it "logs and saves error if merge is #{merge_method} only" do + merge_method = 'rebase_merge' if merge_method == 'semi-linear' + merge_request.project.update(merge_method: merge_method) + error_message = 'Only fast-forward merge is allowed for your project. Please update your source branch' + allow(service).to receive(:execute_hooks) + + service.execute(merge_request) + + expect(merge_request).to be_open + expect(merge_request.merge_commit_sha).to be_nil + expect(merge_request.merge_error).to include(error_message) + expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message)) + end + end + end end end end |