Commit b028eb64 authored by Stan Hu's avatar Stan Hu

Merge branch '321376-fj-improve-wiki-empty-method' into 'master'

Avoid creating repository when calling Wiki#empty?

See merge request gitlab-org/gitlab!54062
parents a0cd4c7e 84b5c942
...@@ -104,7 +104,7 @@ class Wiki ...@@ -104,7 +104,7 @@ class Wiki
end end
def empty? def empty?
list_pages(limit: 1).empty? !repository_exists? || list_pages(limit: 1).empty?
end end
def exists? def exists?
......
...@@ -154,6 +154,15 @@ RSpec.shared_examples 'wiki model' do ...@@ -154,6 +154,15 @@ RSpec.shared_examples 'wiki model' do
it 'returns true' do it 'returns true' do
expect(subject.empty?).to be(true) expect(subject.empty?).to be(true)
end end
context 'when the repository does not exist' do
let(:wiki_container) { wiki_container_without_repo }
it 'returns true and does not create the repo' do
expect(subject.empty?).to be(true)
expect(wiki.repository_exists?).to be false
end
end
end end
context 'when the wiki has pages' do context 'when the wiki has pages' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment