summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-09-28 17:09:35 +0100
committerSean McGivern <sean@gitlab.com>2017-09-28 17:09:35 +0100
commitdc32128de976d864ca143c4b56fa1b45531e277e (patch)
tree1aa1166f6aa2461895bfd5760c8a4ac0b9f2cf5d /spec/services
parent3209c071402cc14b006aabd45bd310395cef53a5 (diff)
downloadgitlab-ce-dc32128de976d864ca143c4b56fa1b45531e277e.tar.gz
Clear merge requests counter cache after merge
Before this change, the MR counter in the sidebar would be wrong if an MR had been merged since the last update, but not opened or closed, as merging did not trigger a counter cache update.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/merge_requests/post_merge_service_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/services/merge_requests/post_merge_service_spec.rb b/spec/services/merge_requests/post_merge_service_spec.rb
index a37cdab8928..d2bd05d921f 100644
--- a/spec/services/merge_requests/post_merge_service_spec.rb
+++ b/spec/services/merge_requests/post_merge_service_spec.rb
@@ -11,5 +11,16 @@ describe MergeRequests::PostMergeService do
describe '#execute' do
it_behaves_like 'cache counters invalidator'
+
+ it 'refreshes the number of open merge requests for a valid MR', :use_clean_rails_memory_store_caching do
+ # Cache the counter before the MR changed state.
+ project.open_merge_requests_count
+ merge_request.update!(state: 'merged')
+
+ service = described_class.new(project, user, {})
+
+ expect { service.execute(merge_request) }
+ .to change { project.open_merge_requests_count }.from(1).to(0)
+ end
end
end