summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-03-17 18:15:09 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-03-17 21:45:43 +0100
commitdd4b789765ca4219f89c03d14d0c2524b2374184 (patch)
treed11c040bc4ba181adf27a22460b5fcc85fef5ffa
parent3d7feeede32a81df06f80f6f3599bfe62aa6e13d (diff)
downloadgitlab-ce-dd4b789765ca4219f89c03d14d0c2524b2374184.tar.gz
Added tests for Repository#build_cacheproject-cache-worker-without-diverging
-rw-r--r--spec/models/repository_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 536fe66b21b..a57229a4fdf 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -780,4 +780,34 @@ describe Repository, models: true do
end
end
end
+
+ describe '#build_cache' do
+ let(:cache) { repository.send(:cache) }
+
+ it 'builds the caches if they do not already exist' do
+ expect(cache).to receive(:exist?).
+ exactly(repository.cache_keys.length).
+ times.
+ and_return(false)
+
+ repository.cache_keys.each do |key|
+ expect(repository).to receive(key)
+ end
+
+ repository.build_cache
+ end
+
+ it 'does not build any caches that already exist' do
+ expect(cache).to receive(:exist?).
+ exactly(repository.cache_keys.length).
+ times.
+ and_return(true)
+
+ repository.cache_keys.each do |key|
+ expect(repository).to_not receive(key)
+ end
+
+ repository.build_cache
+ end
+ end
end