diff options
author | Stan Hu <stanhu@gmail.com> | 2019-01-08 11:37:54 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-01-08 13:14:06 -0800 |
commit | e884795e6c449b2757de72035b919dbce6e76211 (patch) | |
tree | 1e73514de28c8a1b32f262e90b9739321b7e95a7 /spec/lib/gitlab/repository_cache_spec.rb | |
parent | 1b3affafab0f28c690ce93cc98ac6bd09cbda59f (diff) | |
download | gitlab-ce-e884795e6c449b2757de72035b919dbce6e76211.tar.gz |
Revert "Merge branch '3062-improve-project-cache' into 'master'"
This reverts commit e65e184269bb27661c9a20658933e8482aa90b62, reversing
changes made to 646ba2418b630710edeaac94b57d08adf2771257.
Diffstat (limited to 'spec/lib/gitlab/repository_cache_spec.rb')
-rw-r--r-- | spec/lib/gitlab/repository_cache_spec.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/spec/lib/gitlab/repository_cache_spec.rb b/spec/lib/gitlab/repository_cache_spec.rb index 1b9a8b4ab0d..741ee12633f 100644 --- a/spec/lib/gitlab/repository_cache_spec.rb +++ b/spec/lib/gitlab/repository_cache_spec.rb @@ -4,14 +4,14 @@ describe Gitlab::RepositoryCache do let(:backend) { double('backend').as_null_object } let(:project) { create(:project) } let(:repository) { project.repository } - let(:namespace) { "project:#{project.id}" } + let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository, backend: backend) } describe '#cache_key' do subject { cache.cache_key(:foo) } it 'includes the namespace' do - expect(subject).to eq "#{namespace}:foo" + expect(subject).to eq "foo:#{namespace}" end context 'with a given namespace' do @@ -22,7 +22,7 @@ describe Gitlab::RepositoryCache do end it 'includes the full namespace' do - expect(subject).to eq "#{namespace}:#{extra_namespace}:foo" + expect(subject).to eq "foo:#{namespace}:#{extra_namespace}" end end end @@ -30,21 +30,21 @@ describe Gitlab::RepositoryCache do describe '#expire' do it 'expires the given key from the cache' do cache.expire(:foo) - expect(backend).to have_received(:delete).with("#{namespace}:foo") + expect(backend).to have_received(:delete).with("foo:#{namespace}") end end describe '#fetch' do it 'fetches the given key from the cache' do cache.fetch(:bar) - expect(backend).to have_received(:fetch).with("#{namespace}:bar") + expect(backend).to have_received(:fetch).with("bar:#{namespace}") end it 'accepts a block' do p = -> {} cache.fetch(:baz, &p) - expect(backend).to have_received(:fetch).with("#{namespace}:baz", &p) + expect(backend).to have_received(:fetch).with("baz:#{namespace}", &p) end end @@ -67,7 +67,7 @@ describe Gitlab::RepositoryCache do end it 'caches the value' do - expect(backend).to receive(:write).with("#{namespace}:#{key}", true) + expect(backend).to receive(:write).with("#{key}:#{namespace}", true) cache.fetch_without_caching_false(key) { true } end @@ -83,7 +83,7 @@ describe Gitlab::RepositoryCache do end it 'does not cache the value' do - expect(backend).not_to receive(:write).with("#{namespace}:#{key}", true) + expect(backend).not_to receive(:write).with("#{key}:#{namespace}", true) cache.fetch_without_caching_false(key, &p) end @@ -92,7 +92,7 @@ describe Gitlab::RepositoryCache do context 'when the cached value is truthy' do before do - backend.write("#{namespace}:#{key}", true) + backend.write("#{key}:#{namespace}", true) end it 'returns the cached value' do @@ -116,7 +116,7 @@ describe Gitlab::RepositoryCache do context 'when the cached value is falsey' do before do - backend.write("#{namespace}:#{key}", false) + backend.write("#{key}:#{namespace}", false) end it 'returns the result of the block' do @@ -126,7 +126,7 @@ describe Gitlab::RepositoryCache do end it 'writes the truthy value to the cache' do - expect(backend).to receive(:write).with("#{namespace}:#{key}", 'block result') + expect(backend).to receive(:write).with("#{key}:#{namespace}", 'block result') cache.fetch_without_caching_false(key) { 'block result' } end |