Make it possible to resolve all todos for pipeline

This commit is contained in:
Grzegorz Bizon 2017-02-15 10:54:33 +01:00
parent fc13312946
commit 25b3b2e5bc
2 changed files with 30 additions and 1 deletions

View file

@ -18,5 +18,11 @@ module MergeRequests
todo_service.merge_request_build_retried(merge_request) todo_service.merge_request_build_retried(merge_request)
end end
end end
def close_all(pipeline)
pipeline_merge_requests(pipeline) do |merge_request|
todo_service.merge_request_build_retried(merge_request)
end
end
end end
end end

View file

@ -17,7 +17,7 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
described_class.new(project, user, commit_message: 'Awesome message') described_class.new(project, user, commit_message: 'Awesome message')
end end
let(:todo_service) { TodoService.new } let(:todo_service) { spy('todo service') }
let(:merge_request) do let(:merge_request) do
create(:merge_request, merge_user: user, create(:merge_request, merge_user: user,
@ -107,4 +107,27 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
end end
end end
end end
describe '#close_all' do
context 'when using pipeline that belongs to merge request' do
it 'resolves todos about failed builds for pipeline' do
service.close_all(pipeline)
expect(todo_service)
.to have_received(:merge_request_build_retried)
.with(merge_request)
end
end
context 'when pipeline is not related to merge request' do
let(:pipeline) { create(:ci_empty_pipeline) }
it 'does not resolve any todos about failed builds' do
service.close_all(pipeline)
expect(todo_service)
.not_to have_received(:merge_request_build_retried)
end
end
end
end end