Commit 4d647a21 authored by Stan Hu's avatar Stan Hu

Merge branch '296842-invalidate-reviewer-counter-on-create' into 'master'

Invalidate reviews counter cache when MR gets created

See merge request gitlab-org/gitlab!51316
parents 1d219b5c 2120b071
......@@ -158,7 +158,9 @@ class IssuableBaseService < BaseService
after_create(issuable)
execute_hooks(issuable)
invalidate_cache_counts(issuable, users: issuable.assignees)
users_to_invalidate = issuable.allows_reviewers? ? issuable.assignees | issuable.reviewers : issuable.assignees
invalidate_cache_counts(issuable, users: users_to_invalidate)
issuable.update_project_counter_caches
end
......
---
title: Invalidate reviews counter cache when MR gets created
merge_request: 51316
author:
type: fixed
......@@ -155,6 +155,12 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
expect(Todo.where(attributes).count).to eq 1
end
it 'invalidates counter cache for reviewers', :use_clean_rails_memory_store_caching do
expect { merge_request }
.to change { user2.review_requested_open_merge_requests_count }
.by(1)
end
end
context 'when head pipelines already exist for merge request source branch', :sidekiq_inline 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