gollum 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gollum might be problematic. Click here for more details.
- data/Gemfile +1 -1
- data/README.md +24 -1
- data/Rakefile +2 -2
- data/bin/gollum +1 -1
- data/gollum.gemspec +24 -169
- data/lib/gollum.rb +1 -1
- data/lib/gollum/frontend/app.rb +12 -7
- data/lib/gollum/frontend/helpers.rb +6 -0
- data/lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png +0 -0
- data/lib/gollum/frontend/public/gollum/livepreview/index.html +0 -6
- data/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +0 -2
- data/lib/gollum/frontend/public/gollum/livepreview/licenses/licenses.txt +7 -0
- data/lib/gollum/frontend/public/gollum/livepreview/licenses/templarian_windowsicons/license.txt +40 -0
- data/lib/gollum/gitcode.rb +47 -0
- data/lib/gollum/markup.rb +58 -8
- data/lib/gollum/wiki.rb +7 -2
- data/templates/helper_wiki.rb +9 -0
- metadata +261 -429
- data/test/examples/empty.git/HEAD +0 -1
- data/test/examples/empty.git/config +0 -5
- data/test/examples/empty.git/description +0 -1
- data/test/examples/empty.git/hooks/applypatch-msg.sample +0 -15
- data/test/examples/empty.git/hooks/commit-msg.sample +0 -24
- data/test/examples/empty.git/hooks/post-commit.sample +0 -8
- data/test/examples/empty.git/hooks/post-receive.sample +0 -15
- data/test/examples/empty.git/hooks/post-update.sample +0 -8
- data/test/examples/empty.git/hooks/pre-applypatch.sample +0 -14
- data/test/examples/empty.git/hooks/pre-commit.sample +0 -46
- data/test/examples/empty.git/hooks/pre-rebase.sample +0 -169
- data/test/examples/empty.git/hooks/prepare-commit-msg.sample +0 -36
- data/test/examples/empty.git/hooks/update.sample +0 -128
- data/test/examples/empty.git/info/exclude +0 -6
- data/test/examples/empty.git/objects/info/.gitkeep +0 -0
- data/test/examples/empty.git/objects/pack/.gitkeep +0 -0
- data/test/examples/empty.git/refs/heads/.gitkeep +0 -0
- data/test/examples/lotr.git/COMMIT_EDITMSG +0 -1
- data/test/examples/lotr.git/HEAD +0 -1
- data/test/examples/lotr.git/ORIG_HEAD +0 -1
- data/test/examples/lotr.git/config +0 -12
- data/test/examples/lotr.git/description +0 -1
- data/test/examples/lotr.git/index +0 -0
- data/test/examples/lotr.git/info/exclude +0 -6
- data/test/examples/lotr.git/logs/HEAD +0 -7
- data/test/examples/lotr.git/logs/refs/heads/master +0 -7
- data/test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5 +0 -0
- data/test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44 +0 -0
- data/test/examples/lotr.git/objects/0d/c9016ca928c78d5421a99a53b379b53929221e +0 -0
- data/test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef +0 -3
- data/test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b +0 -0
- data/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 +0 -0
- data/test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 +0 -2
- data/test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5 +0 -0
- data/test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9 +0 -0
- data/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 +0 -0
- data/test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad +0 -4
- data/test/examples/lotr.git/objects/45/3b250f979c7bd6dfb62640c944c982ae6721ee +0 -0
- data/test/examples/lotr.git/objects/45/f319ee12f2b551b901b22e72602963c366fff1 +0 -0
- data/test/examples/lotr.git/objects/46/a697caf435815bb07bbce947fc2d58be15f087 +0 -0
- data/test/examples/lotr.git/objects/4c/45c2b4e297a726c3d3f66886f35373e48fe1c5 +0 -2
- data/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 +0 -0
- data/test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa +0 -0
- data/test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b +0 -0
- data/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 +0 -1
- data/test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71 +0 -0
- data/test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f +0 -0
- data/test/examples/lotr.git/objects/7b/60c5a20a501a70f2317fa0ef763e1e2ce22d6b +0 -0
- data/test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979 +0 -0
- data/test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10 +0 -0
- data/test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675 +0 -0
- data/test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d +0 -2
- data/test/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809 +0 -0
- data/test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1 +0 -0
- data/test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6 +0 -0
- data/test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814 +0 -0
- data/test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14 +0 -4
- data/test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813 +0 -0
- data/test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68 +0 -0
- data/test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c +0 -0
- data/test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd +0 -0
- data/test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60 +0 -0
- data/test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05 +0 -0
- data/test/examples/lotr.git/objects/c9/6a7645db5d4c76389e77cd103ef3ed77d81e4c +0 -0
- data/test/examples/lotr.git/objects/ca/7355dc497e9729fbaf0c0e3f424b86afef5614 +0 -0
- data/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd +0 -2
- data/test/examples/lotr.git/objects/d5/29304506d37f544675244c335d85cab5d29966 +0 -0
- data/test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19 +0 -0
- data/test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83 +0 -0
- data/test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961 +0 -0
- data/test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465 +0 -3
- data/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df +0 -1
- data/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 +0 -0
- data/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 +0 -0
- data/test/examples/lotr.git/objects/info/packs +0 -2
- data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx +0 -0
- data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack +0 -0
- data/test/examples/lotr.git/packed-refs +0 -2
- data/test/examples/lotr.git/refs/heads/master +0 -1
- data/test/examples/lotr.git/refs/remotes/origin/HEAD +0 -1
- data/test/examples/page_file_dir.git/COMMIT_EDITMSG +0 -1
- data/test/examples/page_file_dir.git/HEAD +0 -1
- data/test/examples/page_file_dir.git/config +0 -6
- data/test/examples/page_file_dir.git/description +0 -1
- data/test/examples/page_file_dir.git/index +0 -0
- data/test/examples/page_file_dir.git/info/exclude +0 -6
- data/test/examples/page_file_dir.git/logs/HEAD +0 -1
- data/test/examples/page_file_dir.git/logs/refs/heads/master +0 -1
- data/test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf +0 -0
- data/test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e +0 -0
- data/test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
- data/test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
- data/test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2 +0 -0
- data/test/examples/page_file_dir.git/refs/heads/master +0 -1
- data/test/examples/revert.git/COMMIT_EDITMSG +0 -1
- data/test/examples/revert.git/HEAD +0 -1
- data/test/examples/revert.git/config +0 -12
- data/test/examples/revert.git/description +0 -1
- data/test/examples/revert.git/index +0 -0
- data/test/examples/revert.git/info/exclude +0 -6
- data/test/examples/revert.git/logs/HEAD +0 -3
- data/test/examples/revert.git/logs/refs/heads/master +0 -3
- data/test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab +0 -0
- data/test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d +0 -0
- data/test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9 +0 -0
- data/test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708 +0 -0
- data/test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa +0 -0
- data/test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc +0 -0
- data/test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023 +0 -3
- data/test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433 +0 -0
- data/test/examples/revert.git/objects/info/packs +0 -2
- data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx +0 -0
- data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack +0 -0
- data/test/examples/revert.git/packed-refs +0 -2
- data/test/examples/revert.git/refs/heads/master +0 -1
- data/test/examples/revert.git/refs/remotes/origin/HEAD +0 -1
- data/test/examples/yubiwa.git/HEAD +0 -1
- data/test/examples/yubiwa.git/config +0 -5
- data/test/examples/yubiwa.git/description +0 -1
- data/test/examples/yubiwa.git/info/exclude +0 -6
- data/test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00 +0 -0
- data/test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de +0 -0
- data/test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835 +0 -0
- data/test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8 +0 -1
- data/test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70 +0 -0
- data/test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b +0 -0
- data/test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309 +0 -0
- data/test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34 +0 -0
- data/test/examples/yubiwa.git/refs/heads/master +0 -1
- data/test/file_view/1_file.txt +0 -3
- data/test/file_view/1_file_1_folder.txt +0 -8
- data/test/file_view/1_folder.txt +0 -8
- data/test/file_view/2_files_2_folders.txt +0 -12
- data/test/file_view/2_files_2_folders_1_root.txt +0 -13
- data/test/file_view/nested_folders.txt +0 -28
- data/test/helper.rb +0 -66
- data/test/test_app.rb +0 -375
- data/test/test_app_helpers.rb +0 -13
- data/test/test_committer.rb +0 -64
- data/test/test_file.rb +0 -27
- data/test/test_file_view.rb +0 -102
- data/test/test_git_access.rb +0 -53
- data/test/test_markup.rb +0 -732
- data/test/test_page.rb +0 -231
- data/test/test_page_revert.rb +0 -57
- data/test/test_pages_view.rb +0 -46
- data/test/test_unicode.rb +0 -131
- data/test/test_wiki.rb +0 -509
data/test/test_page.rb
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
# ~*~ encoding: utf-8 ~*~
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
3
|
-
|
4
|
-
context "Page" do
|
5
|
-
setup do
|
6
|
-
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
7
|
-
end
|
8
|
-
|
9
|
-
test "new page" do
|
10
|
-
page = Gollum::Page.new(@wiki)
|
11
|
-
assert_nil page.raw_data
|
12
|
-
assert_nil page.formatted_data
|
13
|
-
end
|
14
|
-
|
15
|
-
test "get existing page" do
|
16
|
-
page = @wiki.page('Bilbo Baggins')
|
17
|
-
assert_equal Gollum::Page, page.class
|
18
|
-
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
19
|
-
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a>\n</h1>\n\n<p>Bilbo Baggins}
|
20
|
-
assert_equal 'Bilbo-Baggins.md', page.path
|
21
|
-
assert_equal :markdown, page.format
|
22
|
-
assert_equal @wiki.repo.commits.first.id, page.version.id
|
23
|
-
end
|
24
|
-
|
25
|
-
test "get existing page case insensitive" do
|
26
|
-
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('bilbo baggins').path
|
27
|
-
end
|
28
|
-
|
29
|
-
test "get existing page with hyphen" do
|
30
|
-
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('Bilbo-Baggins').path
|
31
|
-
end
|
32
|
-
|
33
|
-
test "get existing page with underscore" do
|
34
|
-
assert_nil @wiki.page('Bilbo_Baggins')
|
35
|
-
end
|
36
|
-
|
37
|
-
test "get existing page where filename contains whitespace, with hypen" do
|
38
|
-
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise-Gamgee').path
|
39
|
-
end
|
40
|
-
|
41
|
-
test "get existing page where filename contains whitespace, with underscore" do
|
42
|
-
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise_Gamgee').path
|
43
|
-
end
|
44
|
-
|
45
|
-
test "get existing page where filename contains whitespace, with whitespace" do
|
46
|
-
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise Gamgee').path
|
47
|
-
end
|
48
|
-
|
49
|
-
test "get nested page" do
|
50
|
-
page = @wiki.page('Eye Of Sauron')
|
51
|
-
assert_equal 'Mordor/Eye-Of-Sauron.md', page.path
|
52
|
-
end
|
53
|
-
|
54
|
-
test "url_path" do
|
55
|
-
page = @wiki.page('Bilbo Baggins')
|
56
|
-
assert_equal 'Bilbo-Baggins', page.url_path
|
57
|
-
end
|
58
|
-
|
59
|
-
test "nested url_path" do
|
60
|
-
page = @wiki.page('Eye Of Sauron')
|
61
|
-
assert_equal 'Mordor/Eye-Of-Sauron', page.url_path
|
62
|
-
end
|
63
|
-
|
64
|
-
test "page versions" do
|
65
|
-
page = @wiki.page('Bilbo Baggins')
|
66
|
-
assert_equal ["f25eccd98e9b667f9e22946f3e2f945378b8a72d", "5bc1aaec6149e854078f1d0f8b71933bbc6c2e43"],
|
67
|
-
page.versions.map { |v| v.id }
|
68
|
-
end
|
69
|
-
|
70
|
-
test "page versions across renames" do
|
71
|
-
page = @wiki.page 'My-Precious'
|
72
|
-
assert_equal ['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b', '94523d7ae48aeba575099dd12926420d8fd0425d'],
|
73
|
-
page.versions(:follow => true).map { |v| v.id }
|
74
|
-
end
|
75
|
-
|
76
|
-
test "page versions without renames" do
|
77
|
-
page = @wiki.page 'My-Precious'
|
78
|
-
assert_equal ['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'],
|
79
|
-
page.versions(:follow => false).map { |v| v.id }
|
80
|
-
end
|
81
|
-
|
82
|
-
test "specific page version" do
|
83
|
-
page = @wiki.page('Bilbo Baggins', 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb')
|
84
|
-
assert_equal 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb', page.version.id
|
85
|
-
end
|
86
|
-
|
87
|
-
test "no page match" do
|
88
|
-
assert_nil @wiki.page('I do not exist')
|
89
|
-
end
|
90
|
-
|
91
|
-
test "no version match" do
|
92
|
-
assert_nil @wiki.page('Bilbo Baggins', 'I do not exist')
|
93
|
-
end
|
94
|
-
|
95
|
-
test "no ext match" do
|
96
|
-
assert_nil @wiki.page('Data')
|
97
|
-
end
|
98
|
-
|
99
|
-
test "cname" do
|
100
|
-
assert_equal "Foo", Gollum::Page.cname("Foo")
|
101
|
-
assert_equal "Foo-Bar", Gollum::Page.cname("Foo Bar")
|
102
|
-
# / is now a directory delimiter so it must be preserved
|
103
|
-
assert_equal "Foo-/-Bar", Gollum::Page.cname("Foo / Bar")
|
104
|
-
assert_equal "José", Gollum::Page.cname("José")
|
105
|
-
assert_equal "モルドール", Gollum::Page.cname("モルドール")
|
106
|
-
end
|
107
|
-
|
108
|
-
test "title from filename with normal contents" do
|
109
|
-
page = @wiki.page('Bilbo Baggins')
|
110
|
-
assert_equal 'Bilbo Baggins', page.title
|
111
|
-
end
|
112
|
-
|
113
|
-
test "title from filename with html contents" do
|
114
|
-
page = @wiki.page('My <b>Precious', '0ed8cbe0a25235bd867e65193c7d837c66b328ef')
|
115
|
-
assert_equal 'My Precious', page.title
|
116
|
-
end
|
117
|
-
|
118
|
-
test "title from filename with normal contents" do
|
119
|
-
page = @wiki.page('Home')
|
120
|
-
assert_equal "Home", page.title
|
121
|
-
end
|
122
|
-
|
123
|
-
test "title from filename with html contents" do
|
124
|
-
page = @wiki.page('Eye Of Sauron')
|
125
|
-
assert_equal "Eye Of Sauron", page.title
|
126
|
-
end
|
127
|
-
|
128
|
-
test "top level header" do
|
129
|
-
header = @wiki.page('Home').header
|
130
|
-
assert_equal "Hobbits\n", header.raw_data
|
131
|
-
assert_equal "_Header.md", header.path
|
132
|
-
end
|
133
|
-
|
134
|
-
test "nested header" do
|
135
|
-
header = @wiki.page('Eye Of Sauron').header
|
136
|
-
assert_equal "Sauron\n", header.raw_data
|
137
|
-
assert_equal "Mordor/_Header.md", header.path
|
138
|
-
end
|
139
|
-
|
140
|
-
test "header itself" do
|
141
|
-
header = @wiki.page("_Header")
|
142
|
-
assert_nil header.header
|
143
|
-
assert_nil header.footer
|
144
|
-
assert_nil header.sidebar
|
145
|
-
end
|
146
|
-
|
147
|
-
test "top level footer" do
|
148
|
-
footer = @wiki.page('Home').footer
|
149
|
-
assert_equal 'Lord of the Rings wiki', footer.raw_data
|
150
|
-
assert_equal '_Footer.md', footer.path
|
151
|
-
end
|
152
|
-
|
153
|
-
test "nested footer" do
|
154
|
-
footer = @wiki.page('Eye Of Sauron').footer
|
155
|
-
assert_equal "Ones does not simply **walk** into Mordor!\n", footer.raw_data
|
156
|
-
assert_equal "Mordor/_Footer.md", footer.path
|
157
|
-
end
|
158
|
-
|
159
|
-
test "footer itself" do
|
160
|
-
footer = @wiki.page("_Footer")
|
161
|
-
assert_nil footer.header
|
162
|
-
assert_nil footer.footer
|
163
|
-
assert_nil footer.sidebar
|
164
|
-
end
|
165
|
-
|
166
|
-
test "top level sidebar" do
|
167
|
-
sidebar = @wiki.page('Home').sidebar
|
168
|
-
assert_equal 'Lord of the Rings wiki', sidebar.raw_data
|
169
|
-
assert_equal '_Sidebar.md', sidebar.path
|
170
|
-
end
|
171
|
-
|
172
|
-
test "nested sidebar" do
|
173
|
-
sidebar = @wiki.page('Eye Of Sauron').sidebar
|
174
|
-
assert_equal "Ones does not simply **walk** into Mordor!\n", sidebar.raw_data
|
175
|
-
assert_equal "Mordor/_Sidebar.md", sidebar.path
|
176
|
-
end
|
177
|
-
|
178
|
-
test "sidebar itself" do
|
179
|
-
sidebar = @wiki.page("_Sidebar")
|
180
|
-
assert_nil sidebar.header
|
181
|
-
assert_nil sidebar.footer
|
182
|
-
assert_nil sidebar.sidebar
|
183
|
-
end
|
184
|
-
|
185
|
-
test "cannot convert non string to human readable page title" do
|
186
|
-
assert_equal '', Gollum::Page.cname(nil)
|
187
|
-
assert_equal '', Gollum::Page.cname(3)
|
188
|
-
end
|
189
|
-
|
190
|
-
test "normalize_dir" do
|
191
|
-
assert_equal "", Gollum::BlobEntry.normalize_dir("")
|
192
|
-
assert_equal "", Gollum::BlobEntry.normalize_dir(".")
|
193
|
-
assert_equal "", Gollum::BlobEntry.normalize_dir("/")
|
194
|
-
assert_equal "", Gollum::BlobEntry.normalize_dir("c:/")
|
195
|
-
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("foo")
|
196
|
-
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo")
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context "within a sub-directory" do
|
201
|
-
setup do
|
202
|
-
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => 'Rivendell' })
|
203
|
-
end
|
204
|
-
|
205
|
-
test "get existing page" do
|
206
|
-
page = @wiki.page('Elrond')
|
207
|
-
assert_equal Gollum::Page, page.class
|
208
|
-
assert page.raw_data =~ /^# Elrond\n\nElrond/
|
209
|
-
assert_equal 'Rivendell/Elrond.md', page.path
|
210
|
-
assert_equal :markdown, page.format
|
211
|
-
assert_equal @wiki.repo.commits.first.id, page.version.id
|
212
|
-
end
|
213
|
-
|
214
|
-
test "should not get page from parent dir" do
|
215
|
-
page = @wiki.page('Bilbo Baggins')
|
216
|
-
assert_equal nil, page
|
217
|
-
end
|
218
|
-
|
219
|
-
test "should inherit header/footer/sidebar pages from parent directories" do
|
220
|
-
page = @wiki.page('Elrond')
|
221
|
-
|
222
|
-
assert_equal Gollum::Page, page.sidebar.class
|
223
|
-
assert_equal Gollum::Page, page.header.class
|
224
|
-
assert_equal Gollum::Page, page.footer.class
|
225
|
-
|
226
|
-
assert page.sidebar.raw_data =~ /^Lord of the Rings/
|
227
|
-
assert page.header.raw_data =~ /^Hobbits/
|
228
|
-
assert page.footer.raw_data =~ /^Lord of the Rings/
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
data/test/test_page_revert.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# ~*~ encoding: utf-8 ~*~
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
3
|
-
|
4
|
-
context "Page Reverting" do
|
5
|
-
setup do
|
6
|
-
@path = cloned_testpath("examples/revert.git")
|
7
|
-
@wiki = Gollum::Wiki.new(@path)
|
8
|
-
end
|
9
|
-
|
10
|
-
teardown do
|
11
|
-
FileUtils.rm_rf(@path)
|
12
|
-
end
|
13
|
-
|
14
|
-
=begin
|
15
|
-
# Grit is broken and this test fails often. See #363.
|
16
|
-
test "reverts single commit" do
|
17
|
-
page1 = @wiki.page("B")
|
18
|
-
sha = @wiki.revert_commit('7c45b5f16ff3bae2a0063191ef832701214d4df5')
|
19
|
-
page2 = @wiki.page("B")
|
20
|
-
assert_equal sha, page2.version.sha
|
21
|
-
assert_equal "INITIAL", body=page2.raw_data.strip
|
22
|
-
assert_equal body, File.read(File.join(@path, "B.md")).strip
|
23
|
-
end
|
24
|
-
|
25
|
-
test "reverts single commit for a page" do
|
26
|
-
page1 = nil
|
27
|
-
while (page1 == nil)
|
28
|
-
page1 = @wiki.page('B')
|
29
|
-
end
|
30
|
-
|
31
|
-
sha = @wiki.revert_page(page1, '7c45b5f16ff3bae2a0063191ef832701214d4df5')
|
32
|
-
|
33
|
-
page2 = nil
|
34
|
-
while (page2 == nil)
|
35
|
-
page2 = @wiki.page('B')
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_equal sha, page2.version.sha
|
39
|
-
assert_equal "INITIAL", body=page2.raw_data.strip
|
40
|
-
assert_equal body, File.read(File.join(@path, "B.md")).strip
|
41
|
-
end
|
42
|
-
=end
|
43
|
-
|
44
|
-
test "reverts multiple commits for a page" do
|
45
|
-
page1 = @wiki.page('A')
|
46
|
-
sha = @wiki.revert_page(page1, '302a5491a9a5ba12c7652ac831a44961afa312d2^', 'b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f')
|
47
|
-
page2 = @wiki.page('A')
|
48
|
-
assert_equal sha, page2.version.sha
|
49
|
-
assert_equal "INITIAL", body=page2.raw_data.strip
|
50
|
-
assert_equal body, File.read(File.join(@path, "A.md")).strip
|
51
|
-
end
|
52
|
-
|
53
|
-
test "cannot revert conflicting commit" do
|
54
|
-
page1 = @wiki.page('A')
|
55
|
-
assert_equal false, @wiki.revert_page(page1, '302a5491a9a5ba12c7652ac831a44961afa312d2')
|
56
|
-
end
|
57
|
-
end
|
data/test/test_pages_view.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# ~*~ encoding: utf-8 ~*~
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
3
|
-
require File.expand_path '../../lib/gollum/frontend/views/pages', __FILE__
|
4
|
-
|
5
|
-
FakeResult = Struct.new(:path) do
|
6
|
-
def name
|
7
|
-
File.basename(path, File.extname(path)).gsub("-", " ")
|
8
|
-
end
|
9
|
-
|
10
|
-
def escaped_url_path
|
11
|
-
CGI.escape(path).gsub(/\..+$/, "").gsub("%2F", "/")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "Precious::Views::Pages" do
|
16
|
-
setup do
|
17
|
-
@page = Precious::Views::Pages.new
|
18
|
-
end
|
19
|
-
|
20
|
-
test "breadcrumb" do
|
21
|
-
@page.instance_variable_set("@path", "Mordor/Eye-Of-Sauron/Saruman")
|
22
|
-
@page.instance_variable_set("@base_url", "")
|
23
|
-
assert_equal '<a href="/pages/">Home</a> / <a href="/pages/Mordor/">Mordor</a> / <a href="/pages/Mordor/Eye-Of-Sauron/">Eye-Of-Sauron</a> / Saruman', @page.breadcrumb
|
24
|
-
end
|
25
|
-
|
26
|
-
test "breadcrumb with no path" do
|
27
|
-
assert_equal 'Home', @page.breadcrumb
|
28
|
-
end
|
29
|
-
|
30
|
-
test "files_folders" do
|
31
|
-
@page.instance_variable_set("@path", "Mordor")
|
32
|
-
@page.instance_variable_set("@base_url", "")
|
33
|
-
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
34
|
-
@page.instance_variable_set("@results", results)
|
35
|
-
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
36
|
-
end
|
37
|
-
|
38
|
-
test "base url" do
|
39
|
-
# based on test "files_folders"
|
40
|
-
@page.instance_variable_set("@path", "Mordor")
|
41
|
-
@page.instance_variable_set("@base_url", "/wiki")
|
42
|
-
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
43
|
-
@page.instance_variable_set("@results", results)
|
44
|
-
assert_equal %{<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
45
|
-
end
|
46
|
-
end
|
data/test/test_unicode.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
# ~*~ encoding: utf-8 ~*~
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
3
|
-
|
4
|
-
def utf8(str)
|
5
|
-
str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : str
|
6
|
-
end
|
7
|
-
|
8
|
-
context "Unicode Support" do
|
9
|
-
setup do
|
10
|
-
@path = cloned_testpath("examples/revert.git")
|
11
|
-
@wiki = Gollum::Wiki.new(@path)
|
12
|
-
end
|
13
|
-
|
14
|
-
teardown do
|
15
|
-
FileUtils.rm_rf(@path)
|
16
|
-
end
|
17
|
-
|
18
|
-
test "uri encode" do
|
19
|
-
c = '한글'
|
20
|
-
assert_equal '%ED%95%9C%EA%B8%80', encodeURIComponent(c)
|
21
|
-
assert_equal '%ED%95%9C%EA%B8%80', CGI::escape(c)
|
22
|
-
end
|
23
|
-
|
24
|
-
test "create and read non-latin page with anchor" do
|
25
|
-
@wiki.write_page("test", :markdown, "# 한글")
|
26
|
-
|
27
|
-
page = @wiki.page("test")
|
28
|
-
assert_equal Gollum::Page, page.class
|
29
|
-
assert_equal "# 한글", utf8(page.raw_data)
|
30
|
-
|
31
|
-
# markup.rb
|
32
|
-
# #简介
|
33
|
-
# href.gsub('%', '%25') so the anchor works in Firefox.
|
34
|
-
# <a href="#%25ED%2595%259C%25EA%25B8%2580" id="%ED%95%9C%EA%B8%80" class="anchor"></a>
|
35
|
-
doc = Nokogiri::HTML page.formatted_data
|
36
|
-
h1s = doc / :h1
|
37
|
-
h1 = h1s.first
|
38
|
-
anchors = h1 / :a
|
39
|
-
assert_equal 1, h1s.size
|
40
|
-
assert_equal 1, anchors.size
|
41
|
-
assert_equal '#%25ED%2595%259C%25EA%25B8%2580', anchors[0]['href']
|
42
|
-
assert_equal '%ED%95%9C%EA%B8%80', anchors[0]['id']
|
43
|
-
assert_equal 'anchor', anchors[0]['class']
|
44
|
-
assert_equal '', anchors[0].text
|
45
|
-
end
|
46
|
-
|
47
|
-
test "unicode with existing format rules" do
|
48
|
-
@wiki.write_page("test", :markdown, "# 한글")
|
49
|
-
assert_equal @wiki.page("test").path, @wiki.page("test").path
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "Frontend Unicode support" do
|
54
|
-
include Rack::Test::Methods
|
55
|
-
|
56
|
-
setup do
|
57
|
-
@path = cloned_testpath("examples/revert.git")
|
58
|
-
@wiki = Gollum::Wiki.new(@path)
|
59
|
-
Precious::App.set(:gollum_path, @path)
|
60
|
-
Precious::App.set(:wiki_options, {})
|
61
|
-
end
|
62
|
-
|
63
|
-
teardown do
|
64
|
-
FileUtils.rm_rf(@path)
|
65
|
-
end
|
66
|
-
|
67
|
-
test "creates korean page which contains korean content" do
|
68
|
-
post "/create", :content => '한글 text', :page => "k",
|
69
|
-
:format => 'markdown', :message => 'def'
|
70
|
-
follow_redirect!
|
71
|
-
assert last_response.ok?
|
72
|
-
|
73
|
-
page = @wiki.page('k')
|
74
|
-
assert_equal '한글 text', utf8(page.raw_data)
|
75
|
-
assert_equal 'def', page.version.message
|
76
|
-
end
|
77
|
-
|
78
|
-
test "heavy use 1" do
|
79
|
-
post "/create", :content => '한글 text', :page => "PG",
|
80
|
-
:format => 'markdown', :message => 'def'
|
81
|
-
follow_redirect!
|
82
|
-
assert last_response.ok?
|
83
|
-
|
84
|
-
@wiki.update_page(@wiki.page('PG'), nil, nil, '다른 text', {})
|
85
|
-
page = @wiki.page('PG')
|
86
|
-
assert_equal '다른 text', utf8(page.raw_data)
|
87
|
-
|
88
|
-
post '/edit/PG', :page => 'PG', :content => '바뀐 text', :message => 'ghi'
|
89
|
-
follow_redirect!
|
90
|
-
assert last_response.ok?
|
91
|
-
|
92
|
-
@wiki = Gollum::Wiki.new(@path)
|
93
|
-
page = @wiki.page('PG')
|
94
|
-
assert_equal '바뀐 text', utf8(page.raw_data)
|
95
|
-
assert_equal 'ghi', page.version.message
|
96
|
-
end
|
97
|
-
|
98
|
-
test "heavy use 2" do
|
99
|
-
post "/create", :content => '한글 text', :page => "k",
|
100
|
-
:format => 'markdown', :message => 'def'
|
101
|
-
follow_redirect!
|
102
|
-
assert last_response.ok?
|
103
|
-
|
104
|
-
@wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {})
|
105
|
-
@wiki = Gollum::Wiki.new(@path)
|
106
|
-
page = @wiki.page('k')
|
107
|
-
assert_equal '다른 text', utf8(page.raw_data)
|
108
|
-
|
109
|
-
post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
|
110
|
-
:format => 'markdown', :message => 'ghi'
|
111
|
-
follow_redirect!
|
112
|
-
assert last_response.ok?
|
113
|
-
|
114
|
-
@wiki = Gollum::Wiki.new(@path)
|
115
|
-
page = @wiki.page('k')
|
116
|
-
assert_equal '바뀐 text', utf8(page.raw_data)
|
117
|
-
assert_equal 'ghi', page.version.message
|
118
|
-
end
|
119
|
-
|
120
|
-
test 'transliteration' do
|
121
|
-
# TODO: Remove to_url once write_page changes are merged.
|
122
|
-
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' } )
|
123
|
-
page = @wiki.page('eeeee')
|
124
|
-
assert_equal '한글 text', utf8(page.raw_data)
|
125
|
-
end
|
126
|
-
|
127
|
-
def app
|
128
|
-
Precious::App
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|