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
end
def empty?
list_pages(limit: 1).empty?
!repository_exists? || list_pages(limit: 1).empty?
end
def exists?
......
......@@ -154,6 +154,15 @@ RSpec.shared_examples 'wiki model' do
it 'returns true' do
expect(subject.empty?).to be(true)
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
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