diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-08 14:50:55 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-08 17:40:19 +0300 |
commit | 9a99d8e49dc07faaaa2fae436423e11dab5a7d7e (patch) | |
tree | de208a478614dfc317f444969480fa56013ee809 /spec/services/git_push_service_spec.rb | |
parent | 7322c5a05bc018108123194e4e542bb04d42b2b2 (diff) |
Cache various Repository Git operations
This caches the output of the following methods:
* Repository#empty?
* Repository#has_visible_content?
* Repository#root_ref
The cache for Repository#has_visible_content? is flushed whenever a
commit is pushed to a new branch or an existing branch is removed.
The cache for Repository#root_ref is only flushed whenever a user
changes the default branch of a project. The cache for Repository#empty?
is never explicitly flushed as there's no need for it.
Diffstat (limited to 'spec/services/git_push_service_spec.rb')
-rw-r--r-- | spec/services/git_push_service_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index c1080ef190a..349809743c7 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -21,6 +21,18 @@ describe GitPushService, services: true do end it { is_expected.to be_truthy } + + it 'flushes general cached data' do + expect(project.repository).to receive(:expire_cache) + + subject + end + + it 'flushes the visible content cache' do + expect(project.repository).to receive(:expire_has_visible_content_cache) + + subject + end end context 'existing branch' do @@ -29,6 +41,12 @@ describe GitPushService, services: true do end it { is_expected.to be_truthy } + + it 'flushes general cached data' do + expect(project.repository).to receive(:expire_cache) + + subject + end end context 'rm branch' do @@ -37,6 +55,18 @@ describe GitPushService, services: true do end it { is_expected.to be_truthy } + + it 'flushes the visible content cache' do + expect(project.repository).to receive(:expire_has_visible_content_cache) + + subject + end + + it 'flushes general cached data' do + expect(project.repository).to receive(:expire_cache) + + subject + end end end |