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.

Files changed (166) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +24 -1
  3. data/Rakefile +2 -2
  4. data/bin/gollum +1 -1
  5. data/gollum.gemspec +24 -169
  6. data/lib/gollum.rb +1 -1
  7. data/lib/gollum/frontend/app.rb +12 -7
  8. data/lib/gollum/frontend/helpers.rb +6 -0
  9. data/lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png +0 -0
  10. data/lib/gollum/frontend/public/gollum/livepreview/index.html +0 -6
  11. data/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +0 -2
  12. data/lib/gollum/frontend/public/gollum/livepreview/licenses/licenses.txt +7 -0
  13. data/lib/gollum/frontend/public/gollum/livepreview/licenses/templarian_windowsicons/license.txt +40 -0
  14. data/lib/gollum/gitcode.rb +47 -0
  15. data/lib/gollum/markup.rb +58 -8
  16. data/lib/gollum/wiki.rb +7 -2
  17. data/templates/helper_wiki.rb +9 -0
  18. metadata +261 -429
  19. data/test/examples/empty.git/HEAD +0 -1
  20. data/test/examples/empty.git/config +0 -5
  21. data/test/examples/empty.git/description +0 -1
  22. data/test/examples/empty.git/hooks/applypatch-msg.sample +0 -15
  23. data/test/examples/empty.git/hooks/commit-msg.sample +0 -24
  24. data/test/examples/empty.git/hooks/post-commit.sample +0 -8
  25. data/test/examples/empty.git/hooks/post-receive.sample +0 -15
  26. data/test/examples/empty.git/hooks/post-update.sample +0 -8
  27. data/test/examples/empty.git/hooks/pre-applypatch.sample +0 -14
  28. data/test/examples/empty.git/hooks/pre-commit.sample +0 -46
  29. data/test/examples/empty.git/hooks/pre-rebase.sample +0 -169
  30. data/test/examples/empty.git/hooks/prepare-commit-msg.sample +0 -36
  31. data/test/examples/empty.git/hooks/update.sample +0 -128
  32. data/test/examples/empty.git/info/exclude +0 -6
  33. data/test/examples/empty.git/objects/info/.gitkeep +0 -0
  34. data/test/examples/empty.git/objects/pack/.gitkeep +0 -0
  35. data/test/examples/empty.git/refs/heads/.gitkeep +0 -0
  36. data/test/examples/lotr.git/COMMIT_EDITMSG +0 -1
  37. data/test/examples/lotr.git/HEAD +0 -1
  38. data/test/examples/lotr.git/ORIG_HEAD +0 -1
  39. data/test/examples/lotr.git/config +0 -12
  40. data/test/examples/lotr.git/description +0 -1
  41. data/test/examples/lotr.git/index +0 -0
  42. data/test/examples/lotr.git/info/exclude +0 -6
  43. data/test/examples/lotr.git/logs/HEAD +0 -7
  44. data/test/examples/lotr.git/logs/refs/heads/master +0 -7
  45. data/test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5 +0 -0
  46. data/test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44 +0 -0
  47. data/test/examples/lotr.git/objects/0d/c9016ca928c78d5421a99a53b379b53929221e +0 -0
  48. data/test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef +0 -3
  49. data/test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b +0 -0
  50. data/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 +0 -0
  51. data/test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 +0 -2
  52. data/test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5 +0 -0
  53. data/test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9 +0 -0
  54. data/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 +0 -0
  55. data/test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad +0 -4
  56. data/test/examples/lotr.git/objects/45/3b250f979c7bd6dfb62640c944c982ae6721ee +0 -0
  57. data/test/examples/lotr.git/objects/45/f319ee12f2b551b901b22e72602963c366fff1 +0 -0
  58. data/test/examples/lotr.git/objects/46/a697caf435815bb07bbce947fc2d58be15f087 +0 -0
  59. data/test/examples/lotr.git/objects/4c/45c2b4e297a726c3d3f66886f35373e48fe1c5 +0 -2
  60. data/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 +0 -0
  61. data/test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa +0 -0
  62. data/test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b +0 -0
  63. data/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 +0 -1
  64. data/test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71 +0 -0
  65. data/test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f +0 -0
  66. data/test/examples/lotr.git/objects/7b/60c5a20a501a70f2317fa0ef763e1e2ce22d6b +0 -0
  67. data/test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979 +0 -0
  68. data/test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10 +0 -0
  69. data/test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675 +0 -0
  70. data/test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d +0 -2
  71. data/test/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809 +0 -0
  72. data/test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1 +0 -0
  73. data/test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6 +0 -0
  74. data/test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814 +0 -0
  75. data/test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14 +0 -4
  76. data/test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813 +0 -0
  77. data/test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68 +0 -0
  78. data/test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c +0 -0
  79. data/test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd +0 -0
  80. data/test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60 +0 -0
  81. data/test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05 +0 -0
  82. data/test/examples/lotr.git/objects/c9/6a7645db5d4c76389e77cd103ef3ed77d81e4c +0 -0
  83. data/test/examples/lotr.git/objects/ca/7355dc497e9729fbaf0c0e3f424b86afef5614 +0 -0
  84. data/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd +0 -2
  85. data/test/examples/lotr.git/objects/d5/29304506d37f544675244c335d85cab5d29966 +0 -0
  86. data/test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19 +0 -0
  87. data/test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83 +0 -0
  88. data/test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961 +0 -0
  89. data/test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465 +0 -3
  90. data/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df +0 -1
  91. data/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 +0 -0
  92. data/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 +0 -0
  93. data/test/examples/lotr.git/objects/info/packs +0 -2
  94. data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx +0 -0
  95. data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack +0 -0
  96. data/test/examples/lotr.git/packed-refs +0 -2
  97. data/test/examples/lotr.git/refs/heads/master +0 -1
  98. data/test/examples/lotr.git/refs/remotes/origin/HEAD +0 -1
  99. data/test/examples/page_file_dir.git/COMMIT_EDITMSG +0 -1
  100. data/test/examples/page_file_dir.git/HEAD +0 -1
  101. data/test/examples/page_file_dir.git/config +0 -6
  102. data/test/examples/page_file_dir.git/description +0 -1
  103. data/test/examples/page_file_dir.git/index +0 -0
  104. data/test/examples/page_file_dir.git/info/exclude +0 -6
  105. data/test/examples/page_file_dir.git/logs/HEAD +0 -1
  106. data/test/examples/page_file_dir.git/logs/refs/heads/master +0 -1
  107. data/test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf +0 -0
  108. data/test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e +0 -0
  109. data/test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
  110. data/test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
  111. data/test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2 +0 -0
  112. data/test/examples/page_file_dir.git/refs/heads/master +0 -1
  113. data/test/examples/revert.git/COMMIT_EDITMSG +0 -1
  114. data/test/examples/revert.git/HEAD +0 -1
  115. data/test/examples/revert.git/config +0 -12
  116. data/test/examples/revert.git/description +0 -1
  117. data/test/examples/revert.git/index +0 -0
  118. data/test/examples/revert.git/info/exclude +0 -6
  119. data/test/examples/revert.git/logs/HEAD +0 -3
  120. data/test/examples/revert.git/logs/refs/heads/master +0 -3
  121. data/test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab +0 -0
  122. data/test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d +0 -0
  123. data/test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9 +0 -0
  124. data/test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708 +0 -0
  125. data/test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa +0 -0
  126. data/test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc +0 -0
  127. data/test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023 +0 -3
  128. data/test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433 +0 -0
  129. data/test/examples/revert.git/objects/info/packs +0 -2
  130. data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx +0 -0
  131. data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack +0 -0
  132. data/test/examples/revert.git/packed-refs +0 -2
  133. data/test/examples/revert.git/refs/heads/master +0 -1
  134. data/test/examples/revert.git/refs/remotes/origin/HEAD +0 -1
  135. data/test/examples/yubiwa.git/HEAD +0 -1
  136. data/test/examples/yubiwa.git/config +0 -5
  137. data/test/examples/yubiwa.git/description +0 -1
  138. data/test/examples/yubiwa.git/info/exclude +0 -6
  139. data/test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00 +0 -0
  140. data/test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de +0 -0
  141. data/test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835 +0 -0
  142. data/test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8 +0 -1
  143. data/test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70 +0 -0
  144. data/test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b +0 -0
  145. data/test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309 +0 -0
  146. data/test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34 +0 -0
  147. data/test/examples/yubiwa.git/refs/heads/master +0 -1
  148. data/test/file_view/1_file.txt +0 -3
  149. data/test/file_view/1_file_1_folder.txt +0 -8
  150. data/test/file_view/1_folder.txt +0 -8
  151. data/test/file_view/2_files_2_folders.txt +0 -12
  152. data/test/file_view/2_files_2_folders_1_root.txt +0 -13
  153. data/test/file_view/nested_folders.txt +0 -28
  154. data/test/helper.rb +0 -66
  155. data/test/test_app.rb +0 -375
  156. data/test/test_app_helpers.rb +0 -13
  157. data/test/test_committer.rb +0 -64
  158. data/test/test_file.rb +0 -27
  159. data/test/test_file_view.rb +0 -102
  160. data/test/test_git_access.rb +0 -53
  161. data/test/test_markup.rb +0 -732
  162. data/test/test_page.rb +0 -231
  163. data/test/test_page_revert.rb +0 -57
  164. data/test/test_pages_view.rb +0 -46
  165. data/test/test_unicode.rb +0 -131
  166. data/test/test_wiki.rb +0 -509
@@ -1,13 +0,0 @@
1
- <ol class="tree">
2
- <li class="file"><a href="root">root</a></li>
3
- <li>
4
- <label>folder0</label> <input type="checkbox" checked />
5
- <ol>
6
- <li class="file"><a href="folder0/0">0</a></li>
7
- </ol>
8
- </li>
9
- <li>
10
- <label>folder1</label> <input type="checkbox" checked />
11
- <ol>
12
- <li class="file"><a href="folder1/1">1</a></li>
13
- </ol>
@@ -1,28 +0,0 @@
1
- <ol class="tree">
2
- <li>
3
- <label>folder0</label> <input type="checkbox" checked />
4
- <ol>
5
- <li>
6
- <label>folder1</label> <input type="checkbox" checked />
7
- <ol>
8
- <li>
9
- <label>folder2</label> <input type="checkbox" checked />
10
- <ol>
11
- <li class="file"><a href="folder0/folder1/folder2/0">0</a></li>
12
- </ol>
13
- </li>
14
- <li>
15
- <label>folder3</label> <input type="checkbox" checked />
16
- <ol>
17
- <li class="file"><a href="folder0/folder1/folder3/1">1</a></li>
18
- </ol>
19
- </li>
20
- </ol>
21
- </li>
22
- </ol>
23
- </li>
24
- <li>
25
- <label>folder4</label> <input type="checkbox" checked />
26
- <ol>
27
- <li class="file"><a href="folder4/2">2</a></li>
28
- </ol>
data/test/helper.rb DELETED
@@ -1,66 +0,0 @@
1
- require 'rubygems'
2
- require 'rack/test'
3
- require 'test/unit'
4
- require 'shoulda'
5
- require 'mocha'
6
- require 'fileutils'
7
-
8
- dir = File.dirname(File.expand_path(__FILE__))
9
- $LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
10
- $LOAD_PATH.unshift(dir)
11
-
12
- ENV['RACK_ENV'] = 'test'
13
- require 'gollum'
14
- require 'gollum/frontend/app'
15
-
16
- # Make sure we're in the test dir, the tests expect that to be the current
17
- # directory.
18
- TEST_DIR = File.join(File.dirname(__FILE__), *%w[.])
19
-
20
- def testpath(path)
21
- File.join(TEST_DIR, path)
22
- end
23
-
24
- def cloned_testpath(path)
25
- repo = File.expand_path(testpath(path))
26
- path = File.dirname(repo)
27
- cloned = File.join(path, self.class.name)
28
- FileUtils.rm_rf(cloned)
29
- Dir.chdir(path) do
30
- %x{git clone #{File.basename(repo)} #{self.class.name} 2>/dev/null}
31
- end
32
- cloned
33
- end
34
-
35
- def commit_details
36
- { :message => "Did something at #{Time.now}",
37
- :name => "Tom Preston-Werner",
38
- :email => "tom@github.com" }
39
- end
40
-
41
- def normal(text)
42
- text.gsub!(' ', '')
43
- text.gsub!("\n", '')
44
- text
45
- end
46
-
47
- # test/spec/mini 3
48
- # http://gist.github.com/25455
49
- # chris@ozmm.org
50
- # file:lib/test/spec/mini.rb
51
- def context(*args, &block)
52
- return super unless (name = args.first) && block
53
- require 'test/unit'
54
- klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
55
- def self.test(name, &block)
56
- define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
57
- end
58
- def self.xtest(*args) end
59
- def self.setup(&block) define_method(:setup, &block) end
60
- def self.teardown(&block) define_method(:teardown, &block) end
61
- end
62
- (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
63
- $contexts << klass
64
- klass.class_eval &block
65
- end
66
- $contexts = []
data/test/test_app.rb DELETED
@@ -1,375 +0,0 @@
1
- # ~*~ encoding: utf-8 ~*~
2
- require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
3
-
4
- context "Frontend" do
5
- include Rack::Test::Methods
6
-
7
- setup do
8
- @path = cloned_testpath("examples/revert.git")
9
- @wiki = Gollum::Wiki.new(@path)
10
- Precious::App.set(:gollum_path, @path)
11
- Precious::App.set(:wiki_options, {})
12
- end
13
-
14
- teardown do
15
- FileUtils.rm_rf(@path)
16
- end
17
-
18
- test "retain edit information" do
19
- page1 = 'page1'
20
- user1 = 'user1'
21
- @wiki.write_page(page1, :markdown, '',
22
- { :name => user1, :email => user1 });
23
-
24
- get page1
25
- assert_match /Last edited by <b>user1/, last_response.body
26
-
27
- page2 = 'page2'
28
- user2 = 'user2'
29
- @wiki.write_page(page2, :markdown, '',
30
- { :name => user2, :email => user2 });
31
-
32
- get page2
33
- assert_match /Last edited by <b>user2/, last_response.body
34
-
35
- get page1
36
- assert_match /Last edited by <b>user1/, last_response.body
37
- end
38
-
39
- test "edits page" do
40
- page_1 = @wiki.page('A')
41
- post "/edit/A", :content => 'abc', :page => 'A',
42
- :format => page_1.format, :message => 'def'
43
- follow_redirect!
44
- assert last_response.ok?
45
-
46
- @wiki.clear_cache
47
- page_2 = @wiki.page(page_1.name)
48
- assert_equal 'abc', page_2.raw_data
49
- assert_equal 'def', page_2.version.message
50
- assert_not_equal page_1.version.sha, page_2.version.sha
51
- end
52
-
53
- test "edit page with slash" do
54
- page_1 = @wiki.page('A')
55
- post "/edit/A", :content => 'abc', :page => 'A', :path => '/////',
56
- :format => page_1.format, :message => 'def'
57
- follow_redirect!
58
- assert last_response.ok?
59
- end
60
-
61
- test "edits page header footer and sidebar" do
62
- commits = @wiki.repo.commits('master').size
63
- page_1 = @wiki.page('A')
64
- header_1 = page_1.header
65
- foot_1 = page_1.footer
66
- side_1 = page_1.sidebar
67
-
68
- post "/edit/A", :header => 'header',
69
- :footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
70
- follow_redirect!
71
- assert_equal "/A", last_request.fullpath
72
- assert last_response.ok?
73
-
74
- @wiki.clear_cache
75
- page_2 = @wiki.page(page_1.name)
76
- header_2 = page_2.header
77
- foot_2 = page_2.footer
78
- side_2 = page_2.sidebar
79
- assert_equal page_1.raw_data, page_2.raw_data
80
-
81
- assert_equal 'header', header_2.raw_data
82
- assert_equal 'footer', foot_2.raw_data
83
- assert_equal 'def', foot_2.version.message
84
- assert_not_equal foot_1.version.sha, foot_2.version.sha
85
- assert_not_equal header_1.version.sha, header_2.version.sha
86
-
87
- assert_equal 'sidebar', side_2.raw_data
88
- assert_equal 'def', side_2.version.message
89
- assert_not_equal side_1.version.sha, side_2.version.sha
90
- assert_equal commits+1, @wiki.repo.commits('master').size
91
- end
92
-
93
- test "renames page" do
94
- page_1 = @wiki.page('B')
95
- post "/edit/B", :content => 'abc',
96
- :rename => "C", :page => 'B',
97
- :format => page_1.format, :message => 'def'
98
- follow_redirect!
99
- assert_equal '/c', last_request.fullpath
100
- assert last_response.ok?
101
-
102
- @wiki.clear_cache
103
- assert_nil @wiki.page("B")
104
- page_2 = @wiki.page('C')
105
- assert_equal 'abc', page_2.raw_data
106
- assert_equal 'def', page_2.version.message
107
- assert_not_equal page_1.version.sha, page_2.version.sha
108
- end
109
-
110
- test "creates page" do
111
- post "/create", :content => 'abc', :page => "D",
112
- :format => 'markdown', :message => 'def'
113
- follow_redirect!
114
- assert last_response.ok?
115
-
116
- page = @wiki.page('D')
117
- assert_equal 'abc', page.raw_data
118
- assert_equal 'def', page.version.message
119
- end
120
-
121
- test "creates pages with escaped characters in title" do
122
- post "/create", :content => 'abc', :page => 'Title with spaces',
123
- :format => 'markdown', :message => 'foo'
124
- assert_equal 'http://example.org/title-with-spaces', last_response.headers['Location']
125
- get "/Title-with-spaces"
126
- assert_match /abc/, last_response.body
127
- end
128
-
129
- test "redirects to create on non-existant page" do
130
- name = "E"
131
- get "/#{name}"
132
- follow_redirect!
133
- assert_equal "/create/#{name}", last_request.fullpath
134
- assert last_response.ok?
135
- end
136
-
137
- test "edit redirects to create on non-existant page" do
138
- name = "E"
139
- get "/edit/#{name}"
140
- follow_redirect!
141
- assert_equal "/create/#{name}", last_request.fullpath
142
- assert last_response.ok?
143
- end
144
-
145
- test "create redirects to page if already exists" do
146
- name = "A"
147
- get "/create/#{name}"
148
- follow_redirect!
149
- assert_equal "/#{name}", last_request.fullpath
150
- assert last_response.ok?
151
- end
152
-
153
- test "page create and edit with dash & page rev" do
154
- page = 'c-d-e'
155
- path = 'a/b/' # path must end with /
156
-
157
- post '/create', :content => 'create_msg', :page => page,
158
- :path => path, :format => 'markdown', :message => ''
159
- page_c = @wiki.paged(page, path)
160
- assert_equal 'create_msg', page_c.raw_data
161
-
162
- # must clear or create_msg will be returned
163
- @wiki.clear_cache
164
-
165
- # post '/edit' fails. post '/edit/' works.
166
- post '/edit/', :content => 'edit_msg',
167
- :page => page, :path => path, :message => ''
168
- page_e = @wiki.paged(page, path)
169
- assert_equal 'edit_msg', page_e.raw_data
170
-
171
- @wiki.clear_cache
172
-
173
- # test `get %r{/(.+?)/([0-9a-f]{40})} do` in app.rb
174
- get '/' + page_c.escaped_url_path + '/' + page_c.version.to_s
175
- assert last_response.ok?
176
- assert_match /create_msg/, last_response.body
177
-
178
- get '/' + page_e.escaped_url_path + '/' + page_e.version.to_s
179
- assert last_response.ok?
180
- assert_match /edit_msg/, last_response.body
181
- end
182
-
183
- test "guards against creation of existing page" do
184
- name = "A"
185
- post "/create", :content => 'abc', :page => name,
186
- :format => 'markdown', :message => 'def'
187
- follow_redirect!
188
- assert last_response.ok?
189
-
190
- @wiki.clear_cache
191
- page = @wiki.page(name)
192
- assert_not_equal 'abc', page.raw_data
193
- end
194
-
195
- test "delete a page" do
196
- name = "deleteme"
197
- post "/create", :content => 'abc', :page => name,
198
- :format => 'markdown', :message => 'foo'
199
- page = @wiki.page(name)
200
- assert_equal 'abc', page.raw_data
201
-
202
- get '/delete/' + name
203
-
204
- @wiki.clear_cache
205
- page = @wiki.page(name)
206
- assert_equal nil, page
207
- end
208
-
209
- test "previews content" do
210
- post "/preview", :content => 'abc', :format => 'markdown'
211
- assert last_response.ok?
212
- end
213
-
214
- test "previews content on the first page of an empty wiki" do
215
- @path = cloned_testpath("examples/empty.git")
216
- @wiki = Gollum::Wiki.new(@path)
217
- Precious::App.set(:gollum_path, @path)
218
- Precious::App.set(:wiki_options, {})
219
-
220
- post "/preview", :content => 'abc', :format => 'markdown'
221
- assert last_response.ok?
222
- end
223
-
224
- =begin
225
- # Grit is broken.
226
- test "reverts single commit" do
227
- page1 = @wiki.page('B')
228
-
229
- post "/revert/B/7c45b5f16ff3bae2a0063191ef832701214d4df5"
230
- follow_redirect!
231
- assert last_response.ok?
232
-
233
- @wiki.clear_cache
234
- page2 = @wiki.page('B')
235
- assert_not_equal page1.version.sha, page2.version.sha
236
- assert_equal "INITIAL", page2.raw_data.strip
237
- end
238
-
239
- test "reverts multiple commits" do
240
- page1 = @wiki.page('A')
241
-
242
- post "/revert/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac/b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f"
243
- follow_redirect!
244
- assert last_response.ok?
245
-
246
- @wiki.clear_cache
247
- page2 = @wiki.page('A')
248
- assert_not_equal page1.version.sha, page2.version.sha
249
- assert_equal "INITIAL", page2.raw_data.strip
250
- end
251
- =end
252
-
253
- test "cannot revert conflicting commit" do
254
- page1 = @wiki.page('A')
255
-
256
- post "/revert/A/302a5491a9a5ba12c7652ac831a44961afa312d2"
257
- assert last_response.ok?
258
-
259
- @wiki.clear_cache
260
- page2 = @wiki.page('A')
261
- assert_equal page1.version.sha, page2.version.sha
262
- end
263
-
264
- test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
265
- Precious::App.set(:wiki_options, {})
266
- get "/"
267
- assert_match "http://example.org/Home", last_response.headers['Location']
268
-
269
- Precious::App.set(:wiki_options, { :base_path => '/wiki' })
270
- get "/"
271
- assert_match "http://example.org/wiki/Home", last_response.headers['Location']
272
-
273
- Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
274
- get "/"
275
- assert_match "http://example.org/wiki/Home", last_response.headers['Location']
276
- end
277
-
278
- def app
279
- Precious::App
280
- end
281
- end
282
-
283
- context "Frontend with lotr" do
284
- include Rack::Test::Methods
285
-
286
- setup do
287
- @path = cloned_testpath("examples/lotr.git")
288
- @wiki = Gollum::Wiki.new(@path)
289
- Precious::App.set(:gollum_path, @path)
290
- Precious::App.set(:wiki_options, {})
291
- end
292
-
293
- teardown do
294
- FileUtils.rm_rf(@path)
295
- end
296
-
297
- # Here's the dir structure of lotr.git
298
- #
299
- # .
300
- # ├── Bilbo-Baggins.md
301
- # ├── Data.csv
302
- # ├── Gondor
303
- # │   ├── Boromir.md
304
- # │   ├── _Footer.md
305
- # │   ├── _Header.md
306
- # │   └── _Sidebar.md
307
- # ├── Home.textile
308
- # ├── Mordor
309
- # │   ├── Eye-Of-Sauron.md
310
- # │   ├── _Footer.md
311
- # │   ├── _Header.md
312
- # │   ├── _Sidebar.md
313
- # │   ├── eye.jpg
314
- # │   └── todo.txt
315
- # ├── My-Precious.md
316
- # ├── Samwise\ Gamgee.mediawiki
317
- # ├── _Footer.md
318
- # ├── _Header.md
319
- # └── _Sidebar.md
320
- #
321
-
322
- test "/pages" do
323
- get "/pages"
324
- assert last_response.ok?
325
-
326
- body = last_response.body
327
-
328
- assert body.include?("Bilbo Baggins"), "/pages should include the page 'Bilbo Baggins'"
329
- assert body.include?("Gondor"), "/pages should include the folder 'Gondor'"
330
- assert !body.include?("Boromir"), "/pages should NOT include the page 'Boromir'"
331
- assert body.include?("Mordor"), "/pages should include the folder 'Mordor'"
332
- assert !body.include?("Eye Of Sauron"), "/pages should NOT include the page 'Eye Of Sauron'"
333
- end
334
-
335
- test "/pages/Mordor/" do
336
- get "/pages/Mordor/"
337
- assert last_response.ok?, "/pages/Mordor/ did not respond ok"
338
-
339
- body = last_response.body
340
-
341
- assert !body.include?("Bilbo Baggins"), "/pages/Mordor/ should NOT include the page 'Bilbo Baggins'"
342
- assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
343
- end
344
-
345
- test "create pages within sub-directories" do
346
- post "/create", :content => 'big smelly creatures', :page => 'Orc',
347
- :path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
348
- assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
349
- get "/Mordor/Orc"
350
- assert_match /big smelly creatures/, last_response.body
351
-
352
- post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
353
- :path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
354
- assert_equal 'http://example.org/Mordor/uruk-hai', last_response.headers['Location']
355
- get "/Mordor/Uruk-Hai"
356
- assert_match /really big smelly creatures/, last_response.body
357
- end
358
-
359
- test "edit pages within sub-directories" do
360
- post "/create", :content => 'big smelly creatures', :page => 'Orc',
361
- :path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
362
- assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
363
-
364
- post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
365
- :page => 'Orc', :path => 'Mordor', :message => 'minor edit'
366
- assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
367
-
368
- get "/Mordor/Orc"
369
- assert_match /not so big smelly creatures/, last_response.body
370
- end
371
-
372
- def app
373
- Precious::App
374
- end
375
- end