Commit 38cee0a3 authored by Mark Chao's avatar Mark Chao

Clear approval state caching after update

This is to recompute the new overall_approvers
In this method, the following calls would cause a change in the
database which needs resetting the cache:

- super (which updates MR)
- sync_approval_rules (which updates rule record's approvals_required)
- cleanup_approvers (which removes any approver not mentioned in params)

resetting cache must be done after those three calls,
so moving some calls earlier is required.
However this would not affect outcome.
parent 954f7c73
......@@ -13,6 +13,13 @@ module EE
old_approvers = merge_request.overall_approvers(exclude_code_owners: true)
merge_request = super(merge_request)
sync_approval_rules(merge_request)
if should_remove_old_approvers && merge_request.valid?
cleanup_approvers(merge_request, reload: true)
end
merge_request.reset_approval_cache!
new_approvers = merge_request.overall_approvers(exclude_code_owners: true) - old_approvers
......@@ -21,12 +28,6 @@ module EE
notification_service.add_merge_request_approvers(merge_request, new_approvers, current_user)
end
if should_remove_old_approvers && merge_request.valid?
cleanup_approvers(merge_request, reload: true)
end
sync_approval_rules(merge_request)
merge_request
end
......
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