diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-04-03 12:44:51 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-04-05 05:26:56 +0300 |
commit | fa73f4ee196b8c9d28c3b0b035acdd71d71dadb3 (patch) | |
tree | 16233cb3f29ad35978af388108a0020b29f49eba /spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb | |
parent | b54228ad3d79dc0bd7060128e0b75f68cd1c51d9 (diff) |
Fix merge requst relationships with pipeline in MWPSService
MWPSService currently uses the old pipeline lookup method. It searches
related merge requests with pipeline.ref, however, this doesn't work
for attached/detached merge request pipelines.
Diffstat (limited to 'spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb')
-rw-r--r-- | spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb index af0a214c00f..39a2ef579dd 100644 --- a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb +++ b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb @@ -77,6 +77,22 @@ describe MergeRequests::AddTodoWhenBuildFailsService do service.execute(commit_status) end end + + context 'when build belongs to a merge request pipeline' do + let(:pipeline) do + create(:ci_pipeline, source: :merge_request_event, + ref: merge_request.merge_ref_path, + merge_request: merge_request, + merge_requests_as_head_pipeline: [merge_request]) + end + + let(:commit_status) { create(:ci_build, ref: merge_request.merge_ref_path, pipeline: pipeline) } + + it 'notifies the todo service' do + expect(todo_service).to receive(:merge_request_build_failed).with(merge_request) + service.execute(commit_status) + end + end end describe '#close' do @@ -106,6 +122,22 @@ describe MergeRequests::AddTodoWhenBuildFailsService do service.close(commit_status) end end + + context 'when build belongs to a merge request pipeline' do + let(:pipeline) do + create(:ci_pipeline, source: :merge_request_event, + ref: merge_request.merge_ref_path, + merge_request: merge_request, + merge_requests_as_head_pipeline: [merge_request]) + end + + let(:commit_status) { create(:ci_build, ref: merge_request.merge_ref_path, pipeline: pipeline) } + + it 'notifies the todo service' do + expect(todo_service).to receive(:merge_request_build_retried).with(merge_request) + service.close(commit_status) + end + end end describe '#close_all' do |