summaryrefslogtreecommitdiff
path: root/spec/models/repository_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-06 06:06:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-06 06:06:24 +0000
commitb83314141e6420ca252099665beb520fa2f7da7c (patch)
treee077101a1abdbff51a300c89097d7bea81d72c27 /spec/models/repository_spec.rb
parent7b871b34980ed6b21e080b4937860aaf898b7fa4 (diff)
downloadgitlab-ce-b83314141e6420ca252099665beb520fa2f7da7c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r--spec/models/repository_spec.rb30
1 files changed, 9 insertions, 21 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 7226beacebe..cf9100eb6cf 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1193,33 +1193,21 @@ describe Repository do
end
describe '#has_visible_content?' do
- before do
- # If raw_repository.has_visible_content? gets called more than once then
- # caching is broken. We don't want that.
+ it 'delegates to raw_repository when true' do
expect(repository.raw_repository).to receive(:has_visible_content?)
- .once
- .and_return(result)
- end
-
- context 'when true' do
- let(:result) { true }
+ .and_return(true)
- it 'returns true and caches it' do
- expect(repository.has_visible_content?).to eq(true)
- # Second call hits the cache
- expect(repository.has_visible_content?).to eq(true)
- end
+ expect(repository.has_visible_content?).to eq(true)
end
- context 'when false' do
- let(:result) { false }
+ it 'delegates to raw_repository when false' do
+ expect(repository.raw_repository).to receive(:has_visible_content?)
+ .and_return(false)
- it 'returns false and caches it' do
- expect(repository.has_visible_content?).to eq(false)
- # Second call hits the cache
- expect(repository.has_visible_content?).to eq(false)
- end
+ expect(repository.has_visible_content?).to eq(false)
end
+
+ it_behaves_like 'asymmetric cached method', :has_visible_content?
end
describe '#branch_exists?' do