diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-07-31 19:51:06 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-07-31 19:51:06 +0300 |
commit | dbadf5a57660bea6edf38597af17a32094d5fe1f (patch) | |
tree | 5e19a2f03293eec085159b7295c1612401a366a0 /spec | |
parent | 2519027442a5645cc9467e842172143e3f56c7c3 (diff) | |
parent | a459e45eac290914c864616468f1527f6b1fdaab (diff) |
Merge branch 'mk-fix-wiki-backup' into 'master'
Fix improperly skipped backups of wikis
Closes #28854
See merge request !13096
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/backup/repository_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/lib/gitlab/backup/repository_spec.rb b/spec/lib/gitlab/backup/repository_spec.rb index db860b01ba4..3af69daa585 100644 --- a/spec/lib/gitlab/backup/repository_spec.rb +++ b/spec/lib/gitlab/backup/repository_spec.rb @@ -60,4 +60,58 @@ describe Backup::Repository do end end end + + describe '#empty_repo?' do + context 'for a wiki' do + let(:wiki) { create(:project_wiki) } + + context 'wiki repo has content' do + let!(:wiki_page) { create(:wiki_page, wiki: wiki) } + + before do + wiki.repository.exists? # initial cache + end + + context '`repository.exists?` is incorrectly cached as false' do + before do + repo = wiki.repository + repo.send(:cache).expire(:exists?) + repo.send(:cache).fetch(:exists?) { false } + repo.send(:instance_variable_set, :@exists, false) + end + + it 'returns false, regardless of bad cache value' do + expect(described_class.new.send(:empty_repo?, wiki)).to be_falsey + end + end + + context '`repository.exists?` is correctly cached as true' do + it 'returns false' do + expect(described_class.new.send(:empty_repo?, wiki)).to be_falsey + end + end + end + + context 'wiki repo does not have content' do + context '`repository.exists?` is incorrectly cached as true' do + before do + repo = wiki.repository + repo.send(:cache).expire(:exists?) + repo.send(:cache).fetch(:exists?) { true } + repo.send(:instance_variable_set, :@exists, true) + end + + it 'returns true, regardless of bad cache value' do + expect(described_class.new.send(:empty_repo?, wiki)).to be_truthy + end + end + + context '`repository.exists?` is correctly cached as false' do + it 'returns true' do + expect(described_class.new.send(:empty_repo?, wiki)).to be_truthy + end + end + end + end + end end |