Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-02-09 20:19:12 +0300
committerDouwe Maan <douwe@gitlab.com>2016-02-09 20:19:12 +0300
commit883bbd61ca6f465a8fa15583bcefcafd83e40b02 (patch)
tree53f330b7e97af17a00c5f8d896128d95eae8523f /spec
parentc8b6ec47ade1c8685c085310d650fb9af1c44521 (diff)
parent2ce0d06389c3eb7ac9a2b81f9fd339e7e56512bb (diff)
Merge branch 'smarter-diverging-commit-cache-flushing' into 'master'
Smarter flushing of branch statistics caches This basically ensures we only flush caches of branches whenever we really have to. See commit c514f8b850219cd3e5526e73e1d00e6729e2b466 for the details. cc @joshfng @rspeicher See merge request !2769
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb34
-rw-r--r--spec/services/git_push_service_spec.rb6
2 files changed, 37 insertions, 3 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 753012be578..72b4ac6d660 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -291,6 +291,12 @@ describe Repository, models: true do
repository.expire_cache
end
+
+ it 'expires the caches for a specific branch' do
+ expect(repository).to receive(:expire_branch_cache).with('master')
+
+ repository.expire_cache('master')
+ end
end
describe '#expire_root_ref_cache' do
@@ -320,4 +326,32 @@ describe Repository, models: true do
expect(repository.has_visible_content?).to eq(false)
end
end
+
+ describe '#expire_branch_ache' do
+ # This method is private but we need it for testing purposes. Sadly there's
+ # no other proper way of testing caching operations.
+ let(:cache) { repository.send(:cache) }
+
+ it 'expires the cache for all branches' do
+ expect(cache).to receive(:expire).
+ at_least(repository.branches.length).
+ times
+
+ repository.expire_branch_cache
+ end
+
+ it 'expires the cache for all branches when the root branch is given' do
+ expect(cache).to receive(:expire).
+ at_least(repository.branches.length).
+ times
+
+ repository.expire_branch_cache(repository.root_ref)
+ end
+
+ it 'expires the cache for a specific branch' do
+ expect(cache).to receive(:expire).once
+
+ repository.expire_branch_cache('foo')
+ end
+ end
end
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 349809743c7..eb3a5fe43f5 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -23,7 +23,7 @@ describe GitPushService, services: true do
it { is_expected.to be_truthy }
it 'flushes general cached data' do
- expect(project.repository).to receive(:expire_cache)
+ expect(project.repository).to receive(:expire_cache).with('master')
subject
end
@@ -43,7 +43,7 @@ describe GitPushService, services: true do
it { is_expected.to be_truthy }
it 'flushes general cached data' do
- expect(project.repository).to receive(:expire_cache)
+ expect(project.repository).to receive(:expire_cache).with('master')
subject
end
@@ -63,7 +63,7 @@ describe GitPushService, services: true do
end
it 'flushes general cached data' do
- expect(project.repository).to receive(:expire_cache)
+ expect(project.repository).to receive(:expire_cache).with('master')
subject
end