Allow changine of format in Wiki#update_page.

This commit is contained in:
Tom Preston-Werner
2010-07-13 15:24:12 -07:00
parent 77791940a5
commit 90ba8476b2
5 changed files with 101 additions and 26 deletions
+36 -1
View File
@@ -74,7 +74,7 @@ context "Wiki page writing" do
@wiki.write_page("Gollum", :markdown, "# Gollum", commit)
page = @wiki.page("Gollum")
@wiki.update_page(page, "# Gollum2", commit)
@wiki.update_page(page, :markdown, "# Gollum2", commit)
assert_equal 2, @wiki.repo.commits.size
assert_equal "# Gollum2", @wiki.page("Gollum").raw_data
@@ -83,6 +83,41 @@ context "Wiki page writing" do
assert_equal "tom@github.com", @wiki.repo.commits.first.author.email
end
test "update page with format change" do
commit = { :message => "Gollum page",
:name => "Tom Preston-Werner",
:email => "tom@github.com" }
@wiki.write_page("Gollum", :markdown, "# Gollum", commit)
assert_equal :markdown, @wiki.page("Gollum").format
page = @wiki.page("Gollum")
@wiki.update_page(page, :textile, "h1. Gollum", commit)
assert_equal 2, @wiki.repo.commits.size
assert_equal :textile, @wiki.page("Gollum").format
assert_equal "h1. Gollum", @wiki.page("Gollum").raw_data
end
test "update nested page with format change" do
commit = { :message => "Gollum page",
:name => "Tom Preston-Werner",
:email => "tom@github.com" }
index = @wiki.repo.index
index.add("lotr/Gollum.md", "# Gollum")
index.commit("Add nested page")
page = @wiki.page("Gollum")
assert_equal :markdown, @wiki.page("Gollum").format
@wiki.update_page(page, :textile, "h1. Gollum", commit)
page = @wiki.page("Gollum")
assert_equal "lotr/Gollum.textile", page.path
assert_equal :textile, page.format
assert_equal "h1. Gollum", page.raw_data
end
test "delete root page" do
commit = { :message => "Gollum page",
:name => "Tom Preston-Werner",