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
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-07-24 20:39:28 +0300
committerStan Hu <stanhu@gmail.com>2016-07-25 15:09:28 +0300
commit3618796e15d542293aaa721045ff943d360d963a (patch)
treea9f0f4eaf7c3671b1158f975973765cc38d60563 /spec/lib/repository_cache_spec.rb
parent83180110348af1b244d56e9cdf5f29c5d6f84db0 (diff)
Use project ID in repository cache to prevent stale data from persisting across projects
We have a number of bugs caused by cache keys not being flushed properly during deletion of a project. Add the project ID to ensure this never happens. Closes #20027
Diffstat (limited to 'spec/lib/repository_cache_spec.rb')
-rw-r--r--spec/lib/repository_cache_spec.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/spec/lib/repository_cache_spec.rb b/spec/lib/repository_cache_spec.rb
index 63b5292b098..f227926f39c 100644
--- a/spec/lib/repository_cache_spec.rb
+++ b/spec/lib/repository_cache_spec.rb
@@ -1,33 +1,34 @@
-require_relative '../../lib/repository_cache'
+require 'spec_helper'
describe RepositoryCache, lib: true do
+ let(:project) { create(:project) }
let(:backend) { double('backend').as_null_object }
- let(:cache) { RepositoryCache.new('example', backend) }
+ let(:cache) { RepositoryCache.new('example', project.id, backend) }
describe '#cache_key' do
it 'includes the namespace' do
- expect(cache.cache_key(:foo)).to eq 'foo:example'
+ expect(cache.cache_key(:foo)).to eq "foo:example:#{project.id}"
end
end
describe '#expire' do
it 'expires the given key from the cache' do
cache.expire(:foo)
- expect(backend).to have_received(:delete).with('foo:example')
+ expect(backend).to have_received(:delete).with("foo:example:#{project.id}")
end
end
describe '#fetch' do
it 'fetches the given key from the cache' do
cache.fetch(:bar)
- expect(backend).to have_received(:fetch).with('bar:example')
+ expect(backend).to have_received(:fetch).with("bar:example:#{project.id}")
end
it 'accepts a block' do
p = -> {}
cache.fetch(:baz, &p)
- expect(backend).to have_received(:fetch).with('baz:example', &p)
+ expect(backend).to have_received(:fetch).with("baz:example:#{project.id}", &p)
end
end
end