Commit 17881606 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Reload MRs memoization after diffs creation

parent 5b73e0eb
......@@ -90,6 +90,10 @@ module MergeRequests
merge_request.mark_as_unchecked
UpdateHeadPipelineForMergeRequestWorker.perform_async(merge_request.id)
end
# Upcoming method calls need the refreshed version of
# @source_merge_requests diffs (for MergeRequest#commit_shas for instance).
merge_requests_for_source_branch(reload: true)
end
def reset_merge_when_pipeline_succeeds
......@@ -195,7 +199,8 @@ module MergeRequests
merge_requests.uniq.select(&:source_project)
end
def merge_requests_for_source_branch
def merge_requests_for_source_branch(reload: false)
@source_merge_requests = nil if reload
@source_merge_requests ||= merge_requests_for(@branch_name)
end
......
---
title: Reload MRs memoization after diffs creation
merge_request:
author:
type: fixed
......@@ -74,6 +74,14 @@ describe MergeRequests::RefreshService do
expect(@fork_build_failed_todo).to be_done
end
it 'reloads source branch MRs memoization' do
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') }.to change {
refresh_service.instance_variable_get("@source_merge_requests").first.merge_request_diff
}
end
context 'when source branch ref does not exists' do
before do
DeleteBranchService.new(@project, @user).execute(@merge_request.source_branch)
......
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