Commit 461abaa8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add GollumWiki#empty? method

parent 7af1bc3b
...@@ -45,6 +45,10 @@ class GollumWiki ...@@ -45,6 +45,10 @@ class GollumWiki
end end
end end
def empty?
pages.empty?
end
# Returns an Array of Gitlab WikiPage instances or an # Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages. # empty Array if this Wiki has no pages.
def pages def pages
......
...@@ -86,6 +86,27 @@ describe GollumWiki do ...@@ -86,6 +86,27 @@ describe GollumWiki do
end end
end end
describe "#empty?" do
context "when the wiki repository is empty" do
before do
Gitlab::Shell.any_instance.stub(:add_repository) do
create_temp_repo("#{Rails.root}/tmp/test-git-base-path/non-existant.wiki.git")
end
project.stub(:path_with_namespace).and_return("non-existant")
end
its(:empty?) { should be_true }
end
context "when the wiki has pages" do
before do
create_page("index", "This is an awesome new Gollum Wiki")
end
its(:empty?) { should be_false }
end
end
describe "#pages" do describe "#pages" do
before do before do
create_page("index", "This is an awesome new Gollum Wiki") create_page("index", "This is an awesome new Gollum Wiki")
......
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