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@selenight.nl>2018-12-06 14:29:57 +0300
committerDouwe Maan <douwe@selenight.nl>2018-12-06 14:29:57 +0300
commita7ebb27ac6a8082864bb583a4a39e920524ba4d3 (patch)
tree738dbe1504bc247d662a1d3b517c42024cbf7b8f /spec
parent58cd236af6bd8d8c01cbfbd71d284ada5958c10d (diff)
Revert "Merge branch '3062-improve-project-cache' into 'master'"
This reverts commit e65e184269bb27661c9a20658933e8482aa90b62, reversing changes made to 646ba2418b630710edeaac94b57d08adf2771257. # Conflicts: # lib/gitlab/cache/ci/project_pipeline_status.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/repository_cache_spec.rb22
-rw-r--r--spec/models/repository_spec.rb18
2 files changed, 11 insertions, 29 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
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index f09b4b67061..d6c5b9228c0 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -2339,22 +2339,4 @@ describe Repository do
repository.merge_base('master', 'fix')
end
end
-
- describe '#cache' do
- subject(:cache) { repository.send(:cache) }
-
- it 'returns a RepositoryCache' do
- expect(subject).to be_kind_of Gitlab::RepositoryCache
- end
-
- it 'when is_wiki it includes wiki as part of key' do
- allow(repository).to receive(:is_wiki) { true }
-
- expect(subject.namespace).to include('wiki')
- end
-
- it 'when is_wiki is false extra_namespace is nil' do
- expect(subject.namespace).not_to include('wiki')
- end
- end
end