diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-25 15:26:22 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-30 15:49:40 +0200 |
commit | c158a22fd3cc5c3d60b5e0e1bf44f8aa75617d70 (patch) | |
tree | 666ae3be074ad07b8b056d5b19e931600526a39b /spec/models/issue_spec.rb | |
parent | 9e7e0496ff639d1eec65dcbf1b51edb2262456e2 (diff) | |
download | gitlab-ce-sidebar-cache-updates.tar.gz |
Only update the sidebar count caches when neededsidebar-cache-updates
This ensures the issues/MR cache of the sidebar is only updated when the
state or confidential flags changes, instead of changing this for every
update.
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r-- | spec/models/issue_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index de86788d142..e547da0cfbe 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -769,4 +769,22 @@ describe Issue do expect(described_class.public_only).to eq([public_issue]) end end + + describe '#update_project_counter_caches?' do + it 'returns true when the state changes' do + subject.state = 'closed' + + expect(subject.update_project_counter_caches?).to eq(true) + end + + it 'returns true when the confidential flag changes' do + subject.confidential = true + + expect(subject.update_project_counter_caches?).to eq(true) + end + + it 'returns false when the state or confidential flag did not change' do + expect(subject.update_project_counter_caches?).to eq(false) + end + end end |