Commit 8b293d23 authored by Sean McGivern's avatar Sean McGivern

Merge branch '245263-fix-cleanup-service-no-repository' into 'master'

Do not fail when cleaning up MR with no repository

See merge request gitlab-org/gitlab!47744
parents 2290ec25 6f169b23
......@@ -31,7 +31,7 @@ module MergeRequests
return error('Failed to create keep around refs.') unless kept_around?
return error('Failed to cache merge ref sha.') unless cache_merge_ref_sha
delete_refs
delete_refs if repository.exists?
return error('Failed to update schedule.') unless update_schedule
......
---
title: Do not fail when cleaning up MR with no repository
merge_request: 47744
author:
type: fixed
......@@ -115,6 +115,19 @@ RSpec.describe MergeRequests::CleanupRefsService do
it_behaves_like 'service that does not clean up merge request refs'
end
context 'when repository no longer exists' do
before do
Repositories::DestroyService.new(merge_request.project.repository).execute
end
it 'does not fail and still mark schedule as complete' do
aggregate_failures do
expect(result[:status]).to eq(:success)
expect(merge_request.cleanup_schedule.completed_at).to be_present
end
end
end
end
shared_examples_for 'service that does not clean up merge request refs' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment