Add additional tests to verify that existing filenames are processed properly and not cannonicalized
This commit is contained in:
@@ -1 +1 @@
|
||||
add sidebars
|
||||
Test out whitespace with Sam
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
a8ad3c09dd842a3517085bfadd37718856dee813
|
||||
Binary file not shown.
@@ -1,2 +1,3 @@
|
||||
0000000000000000000000000000000000000000 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b rick <technoweenie@gmail.com> 1291341857 -0800 clone: from /Users/rick/p/gollum/test/examples/lotr.git
|
||||
60f12f4254f58801b9ee7db7bca5fa8aeefaa56b a8ad3c09dd842a3517085bfadd37718856dee813 rick <technoweenie@gmail.com> 1291341922 -0800 commit: add sidebars
|
||||
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
0000000000000000000000000000000000000000 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b rick <technoweenie@gmail.com> 1291341857 -0800 clone: from /Users/rick/p/gollum/test/examples/lotr.git
|
||||
60f12f4254f58801b9ee7db7bca5fa8aeefaa56b a8ad3c09dd842a3517085bfadd37718856dee813 rick <technoweenie@gmail.com> 1291341922 -0800 commit: add sidebars
|
||||
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
x╔нKNд0─aж9┘В┬Q°GЦH#дЦp'vh╔Иt■╕ К┐Ю,Ъм╞╞nК╨pS~]Z══╔`╤▒gK■└ыq┘XС└Фф]╞≤X|╣Y└┌c1Y┼╔╠┬O ┴Б$╙└чП1Ф╜цkО|┘ВC
|
||||
wyzскн|╙]^з▐║Ё,г~зЗв3═╥m┼S└GК╛5Ув;ТЪ'С╘Ш─Мp÷≈║Ш█╚б}3|Пj╬KФWo
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
x�RMK1õ¼¿bè¥
|
||||
e÷¢ÄTPOµ·%È4;Ý6›Y’h-ôÇ;[mK¡!‡äÍLÞG²t²„›Ûë‹)¼c·æHð‚]MÓ,�ǧ p˜(@ëeí#œ4…ÊSPä>Ð
|
||||
<v4Õ¸G³‡¾'_ñ7<A[4o*�$ÝÏÙ×QG��ú
|
||||
¬t�x·9Òìp„²\±M,ØZUe°×ÒB\ËäÇÕJŠ�?»íkóÝ:[6&?D âi/Ì6¬n$qà8^á勜ÚQÖs†Œ2Ó‰uömY±sê`ЉÁ6”6=m÷;¶èÔEGƒë!—²Œ\Q˶ÕÂ_VeÙIX‹ç˜Œ™hÓs�Jàëš}T3Y¦He“RWäó5·ÜSŘK¨‹áTœ>¯¹üOóÇï¹Ê³ShÄA
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
a8ad3c09dd842a3517085bfadd37718856dee813
|
||||
1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3
|
||||
|
||||
@@ -50,7 +50,7 @@ context "Wiki" do
|
||||
end
|
||||
|
||||
test "parents with default master ref" do
|
||||
ref = 'a8ad3c09dd842a3517085bfadd37718856dee813'
|
||||
ref = '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'
|
||||
committer = Gollum::Committer.new(@wiki)
|
||||
assert_equal ref, committer.parents.first.sha
|
||||
end
|
||||
|
||||
@@ -18,9 +18,9 @@ context "GitAccess" do
|
||||
assert @access.ref_map.empty?
|
||||
assert @access.tree_map.empty?
|
||||
@access.tree 'master'
|
||||
assert_equal({"master"=>"a8ad3c09dd842a3517085bfadd37718856dee813"}, @access.ref_map)
|
||||
assert_equal({"master"=>"1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3"}, @access.ref_map)
|
||||
|
||||
map = @access.tree_map['a8ad3c09dd842a3517085bfadd37718856dee813']
|
||||
map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3']
|
||||
assert_equal 'Bilbo-Baggins.md', map[0].path
|
||||
assert_equal '', map[0].dir
|
||||
assert_equal map[0].path, map[0].name
|
||||
|
||||
@@ -25,7 +25,27 @@ context "Page" do
|
||||
test "get existing page case insensitive" do
|
||||
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('bilbo baggins').path
|
||||
end
|
||||
|
||||
test "get existing page with hyphen" do
|
||||
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('Bilbo-Baggins').path
|
||||
end
|
||||
|
||||
test "get existing page with underscore" do
|
||||
assert_nil @wiki.page('Bilbo_Baggins')
|
||||
end
|
||||
|
||||
test "get existing page where filename contains whitespace, with hypen" do
|
||||
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise-Gamgee').path
|
||||
end
|
||||
|
||||
test "get existing page where filename contains whitespace, with underscore" do
|
||||
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise_Gamgee').path
|
||||
end
|
||||
|
||||
test "get existing page where filename contains whitespace, with whitespace" do
|
||||
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise Gamgee').path
|
||||
end
|
||||
|
||||
test "get nested page" do
|
||||
page = @wiki.page('Eye Of Sauron')
|
||||
assert_equal 'Mordor/Eye-Of-Sauron.md', page.path
|
||||
|
||||
+103
-2
@@ -36,12 +36,12 @@ context "Wiki" do
|
||||
test "list pages" do
|
||||
pages = @wiki.pages
|
||||
assert_equal \
|
||||
%w(Bilbo-Baggins.md Eye-Of-Sauron.md Home.textile My-Precious.md),
|
||||
['Bilbo-Baggins.md', 'Eye-Of-Sauron.md', 'Home.textile', 'My-Precious.md', 'Samwise Gamgee.mediawiki'],
|
||||
pages.map { |p| p.filename }.sort
|
||||
end
|
||||
|
||||
test "counts pages" do
|
||||
assert_equal 4, @wiki.size
|
||||
assert_equal 5, @wiki.size
|
||||
end
|
||||
|
||||
test "text_data" do
|
||||
@@ -214,6 +214,64 @@ context "Wiki page writing" do
|
||||
end
|
||||
end
|
||||
|
||||
context "Wiki page writing with whitespace (filename contains whitespace)" do
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
|
||||
test "update_page" do
|
||||
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
|
||||
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, page.name, :textile, "h1. Samwise Gamgee2", commit_details)
|
||||
|
||||
assert_equal :textile, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data
|
||||
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename
|
||||
end
|
||||
|
||||
test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do
|
||||
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
|
||||
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, page.name, :textile, "h1. Samwise Gamgee", commit_details)
|
||||
|
||||
assert_equal :textile, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data
|
||||
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename
|
||||
end
|
||||
|
||||
test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do
|
||||
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
|
||||
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details)
|
||||
|
||||
assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data
|
||||
assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename
|
||||
end
|
||||
|
||||
test "update page with name and format change, verify canonicalization of filename, where filename contains Whitespace" do
|
||||
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
|
||||
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
|
||||
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details)
|
||||
|
||||
assert_equal :textile, @wiki.page("Sam Gamgee").format
|
||||
assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data
|
||||
assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
|
||||
context "Wiki sync with working directory" do
|
||||
setup do
|
||||
@path = testpath('examples/wdtest')
|
||||
@@ -269,6 +327,49 @@ context "Wiki sync with working directory" do
|
||||
end
|
||||
end
|
||||
|
||||
context "Wiki sync with working directory (filename contains whitespace)" do
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
test "update a page with same name and format" do
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, page.name, page.format, "What we need is a few good taters.", commit_details)
|
||||
assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise Gamgee.mediawiki"))
|
||||
end
|
||||
|
||||
test "update a page with different name and same format" do
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, "Sam Gamgee", page.format, "What we need is a few good taters.", commit_details)
|
||||
assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Sam-Gamgee.mediawiki"))
|
||||
assert !File.exist?(File.join(@path, "Samwise Gamgee"))
|
||||
end
|
||||
|
||||
test "update a page with same name and different format" do
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, page.name, :textile, "What we need is a few good taters.", commit_details)
|
||||
assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise Gamgee.textile"))
|
||||
assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki"))
|
||||
end
|
||||
|
||||
test "update a page with different name and different format" do
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.update_page(page, "Sam Gamgee", :textile, "What we need is a few good taters.", commit_details)
|
||||
assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Sam-Gamgee.textile"))
|
||||
assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki"))
|
||||
end
|
||||
|
||||
test "delete a page" do
|
||||
page = @wiki.page("Samwise Gamgee")
|
||||
@wiki.delete_page(page, commit_details)
|
||||
assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki"))
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_r(@path)
|
||||
end
|
||||
end
|
||||
|
||||
context "page_file_dir option" do
|
||||
setup do
|
||||
@path = cloned_testpath('examples/page_file_dir')
|
||||
|
||||
Reference in New Issue
Block a user