New and Rename buttons now support directories

* Also fixes renaming a file from a subdirectory moves it to the root.
  * Add context info option to dialog, used in the new dialog
  * Added CSS to support new context option for dialogs
  * Fix /pages view messing up directory creation in new
  * Removed the Edit and Rename buttons from historic view
This commit is contained in:
Daniel Kimsey
2012-11-30 13:18:42 -05:00
parent 443c453507
commit 8fd8a56893
16 changed files with 413 additions and 35 deletions
+2
View File
@@ -4,6 +4,8 @@
bare = false
logallrefupdates = true
ignorecase = true
[receive]
denyCurrentBranch = ignore
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = /Users/rick/p/gollum/test/examples/revert.git
+1
View File
@@ -1,3 +1,4 @@
0000000000000000000000000000000000000000 7c45b5f16ff3bae2a0063191ef832701214d4df5 rick <technoweenie@gmail.com> 1291942707 -0800 clone: from /Users/rick/p/gollum/test/examples/revert.git
7c45b5f16ff3bae2a0063191ef832701214d4df5 f403b791119f8232b7cb0ba455c624ac6435f433 rick <technoweenie@gmail.com> 1291942743 -0800 commit: add footer and sidebar
f403b791119f8232b7cb0ba455c624ac6435f433 ed6c9f63b98acf73c25b5ffbb38da557d3682023 bootstraponline <cafe@bootstraponline.com> 1336421777 -0600 commit: Add header.
ed6c9f63b98acf73c25b5ffbb38da557d3682023 084a558a1fb3cded23129e2dfad3a17d07d73fd3 Daniel Kimsey <dekimsey@ufl.edu> 1354899095 -0500 push
@@ -1,3 +1,4 @@
0000000000000000000000000000000000000000 7c45b5f16ff3bae2a0063191ef832701214d4df5 rick <technoweenie@gmail.com> 1291942707 -0800 clone: from /Users/rick/p/gollum/test/examples/revert.git
7c45b5f16ff3bae2a0063191ef832701214d4df5 f403b791119f8232b7cb0ba455c624ac6435f433 rick <technoweenie@gmail.com> 1291942743 -0800 commit: add footer and sidebar
f403b791119f8232b7cb0ba455c624ac6435f433 ed6c9f63b98acf73c25b5ffbb38da557d3682023 bootstraponline <cafe@bootstraponline.com> 1336421777 -0600 commit: Add header.
ed6c9f63b98acf73c25b5ffbb38da557d3682023 084a558a1fb3cded23129e2dfad3a17d07d73fd3 Daniel Kimsey <dekimsey@ufl.edu> 1354899095 -0500 push
@@ -0,0 +1,3 @@
xŤŹMjĂ0…»Ö)ć
Š4cËPJ ŮőŇü´˘±]dy‘Ű' ‹÷ń6ĽÇë<×đĄ7U0‹‰PŚÉgĂ ‰
Ł Qz„Xl˘˘Ĺýĺ¦K'b™Rf#*dVJL’‰F‰C
+1 -1
View File
@@ -1 +1 @@
ed6c9f63b98acf73c25b5ffbb38da557d3682023
084a558a1fb3cded23129e2dfad3a17d07d73fd3
+72 -6
View File
@@ -153,22 +153,78 @@ context "Frontend" do
end
test "renames page" do
page_1 = @wiki.page('B')
post "/edit/B", :content => 'abc',
:rename => "C", :page => 'B',
:format => page_1.format, :message => 'def'
page_1 = @wiki.page("B")
post "/rename/B", :rename => "/C", :message => 'def'
follow_redirect!
assert_equal '/c', last_request.fullpath
assert_equal '/C', last_request.fullpath
assert last_response.ok?
@wiki.clear_cache
assert_nil @wiki.page("B")
page_2 = @wiki.page('C')
assert_equal 'abc', page_2.raw_data
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
assert_equal 'def', page_2.version.message
assert_not_equal page_1.version.sha, page_2.version.sha
end
test "renames page catches invalid page" do
# No such page
post "/rename/no-such-file-here", :rename => "/C", :message => 'def'
assert !last_response.ok?
assert_equal last_response.status, 500
end
test "rename page catches empty target" do
# Empty rename target
post "/rename/B", :rename => "", :message => 'def'
assert !last_response.ok?
assert_equal last_response.status, 500
end
test "rename page catches non-existent target" do
# Non-existent rename target
post "/rename/B", :message => 'def'
assert !last_response.ok?
assert_equal last_response.status, 500
end
test "renames page in subdirectory" do
page_1 = @wiki.paged("H", "G")
assert_not_equal page_1, nil
post "/rename/G/H", :rename => "/I/C", :message => 'def'
follow_redirect!
assert_equal '/I/C', last_request.fullpath
assert last_response.ok?
@wiki.clear_cache
assert_nil @wiki.paged("H", "G")
page_2 = @wiki.paged('C', 'I')
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
assert_equal 'def', page_2.version.message
assert_not_equal page_1.version.sha, page_2.version.sha
end
test "renames page relative in subdirectory" do
page_1 = @wiki.paged("H", "G")
assert_not_equal page_1, nil
post "/rename/G/H", :rename => "K/C", :message => 'def'
follow_redirect!
assert_equal '/G/K/C', last_request.fullpath
assert last_response.ok?
@wiki.clear_cache
assert_nil @wiki.paged("H", "G")
page_2 = @wiki.paged('C', 'G/K')
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
assert_equal 'def', page_2.version.message
assert_not_equal page_1.version.sha, page_2.version.sha
end
test "creates page" do
post "/create", :content => 'abc', :page => "D",
:format => 'markdown', :message => 'def'
@@ -212,6 +268,16 @@ context "Frontend" do
assert last_response.ok?
end
test "edit returns nil for non-existant page" do
# post '/edit' fails. post '/edit/' works.
page = 'not-real-page'
path = '/'
post '/edit/', :content => 'edit_msg',
:page => page, :path => path, :message => ''
page_e = @wiki.paged(page, path)
assert_equal nil, page_e
end
test "page create and edit with dash & page rev" do
page = 'c-d-e'
path = 'a/b/' # path must end with /
+133
View File
@@ -527,3 +527,136 @@ context "Wiki page writing with different branch" do
assert_equal nil, @wiki.page("Bilbo")
end
end
context "Renames directory traversal" do
setup do
@path = cloned_testpath("examples/revert.git")
@wiki = Gollum::Wiki.new(@path)
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {})
end
teardown do
FileUtils.rm_rf(@path)
end
test "rename aborts on nil" do
cd = {:message => "def"}
res = @wiki.rename_page(@wiki.page("some-super-fake-page"), "B", cd)
assert !res, "rename did not abort with non-existant page"
res = @wiki.rename_page(@wiki.page("B"), "", cd)
assert !res, "rename did not abort with empty rename"
res = @wiki.rename_page(@wiki.page("B"), nil, cd)
assert !res, "rename did not abort with nil rename"
end
test "rename page no-act" do
# Make sure renames don't do anything if the name is the same.
cd = {:message => "def"}
# B.md => B.md
res = @wiki.rename_page(@wiki.page("B"), "B", cd)
assert !res, "NOOP rename did not abort"
end
test "rename page without directories" do
# Make sure renames work with relative paths.
cd = {:message => "def"}
source = @wiki.page("B")
# B.md => C.md
res = @wiki.rename_page(source, "C", cd)
assert res
renamed_ok(source, @wiki.page("C"))
end
test "rename page with subdirs" do
# Make sure renames in subdirectories happen ok
cd = {:message => "def"}
source = @wiki.paged("H", "G")
# G/H.md => G/F.md
@wiki.rename_page(source, "G/F", cd)
renamed_ok(source, @wiki.paged("F", "G"))
end
test "rename page absolute path is still no-act" do
# Make sure renames don't do anything if the name is the same.
cd = {:message => "def"}
# B.md => B.md
res = @wiki.rename_page(@wiki.page("B"), "/B", cd)
assert !res, "NOOP rename did not abort"
end
test "rename page absolute path NOOPs ok" do
# Make sure renames don't do anything if the name is the same and we are in a subdirectory.
cd = {:message => "def"}
source = @wiki.paged("H", "G")
# G/H.md => G/H.md
res = @wiki.rename_page(source, "/G/H", cd)
assert !res, "NOOP rename did not abort"
end
test "rename page absolute directory" do
# Make sure renames work with absolute paths.
cd = {:message => "def"}
source = @wiki.page("B")
# B.md => C.md
res = @wiki.rename_page(source, "/C", cd)
assert res
renamed_ok(source, @wiki.page("C"))
end
test "rename page absolute directory with subdirs" do
# Make sure renames in subdirectories happen ok
cd = {:message => "def"}
source = @wiki.paged("H", "G")
# G/H.md => G/F.md
@wiki.rename_page(source, "/G/F", cd)
renamed_ok(source, @wiki.paged("F", "G"))
end
test "rename page relative directory with new dir creation" do
# Make sure renames in subdirectories create more subdirectories ok
cd = {:message => "def"}
source = @wiki.paged("H", "G")
# G/H.md => G/K/F.md
assert_not_equal k = @wiki.rename_page(source, "K/F", cd), false
new_page = @wiki.paged("F", "K")
assert_not_equal new_page, nil
renamed_ok(source, new_page)
end
test "rename page absolute directory with subdir creation" do
# Make sure renames in subdirectories create more subdirectories ok
cd = {:message => "def"}
source = @wiki.paged("H", "G")
# G/H.md => G/K/F.md
assert_not_equal @wiki.rename_page(source, "/G/K/F", cd), false
new_page = @wiki.paged("F", "G/K")
assert_not_equal new_page, nil
renamed_ok(source, new_page)
end
def renamed_ok(page_source, page_target)
@wiki.clear_cache
page1 = @wiki.paged(page_source.name, page_source.path)
assert_nil page1
assert_equal "INITIAL\n\nSPAM2\n", page_target.raw_data
assert_equal 'def', page_target.version.message
assert_not_equal page_source.version.sha, page_target.version.sha
end
end