Make the 'New Page' button create pages in sub directories if the user puts a slash in the path/page name.

This commit is contained in:
Darren Oakley
2012-07-09 10:41:51 +01:00
parent 33f133b8b2
commit ac97f7e9a2
3 changed files with 27 additions and 62 deletions
+5 -46
View File
@@ -116,12 +116,6 @@ context "Frontend" do
assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location']
get "/Title-with-spaces"
assert_match /abc/, last_response.body
post "/create", :content => 'ghi', :page => 'Title/with/slashes',
:format => 'markdown', :message => 'bar'
assert_equal 'http://example.org/Title-with-slashes', last_response.headers['Location']
get "/Title-with-slashes"
assert_match /ghi/, last_response.body
end
test "redirects to create on non-existant page" do
@@ -138,7 +132,7 @@ context "Frontend" do
follow_redirect!
assert_equal "/create/#{name}", last_request.fullpath
assert last_response.ok?
end
end
test "create redirects to page if already exists" do
name = "A"
@@ -147,7 +141,7 @@ context "Frontend" do
assert_equal "/#{name}", last_request.fullpath
assert last_response.ok?
end
test "guards against creation of existing page" do
name = "A"
post "/create", :content => 'abc', :page => name,
@@ -216,41 +210,6 @@ context "Frontend" do
end
end
# WTF? Surely this test is wrong...
# In this test repo there is already a file called 'bar.md'.
# This SHOULD raise a Duplicate Page error, no?
# context "Frontend with page-file-dir" do
# include Rack::Test::Methods
# setup do
# @path = cloned_testpath("examples/page_file_dir.git")
# @wiki = Gollum::Wiki.new(@path, { :page_file_dir => "docs" })
# Precious::App.set(:gollum_path, @path)
# Precious::App.set(:wiki_options, { :page_file_dir => "docs" })
# end
# teardown do
# FileUtils.rm_rf(@path)
# end
# test "open existing parent" do
# get "/"
# assert last_response.ok?
# post "/create", :content => "asdf", :page => "bar",
# :format => 'markdown'
# follow_redirect!
# assert last_response.ok?
# # Assert not match.
# assert_equal true, /Duplicate page/.match(last_response.body) == nil
# end
# def app
# Precious::App
# end
# end
context "Frontend with lotr" do
include Rack::Test::Methods
@@ -320,10 +279,10 @@ context "Frontend with lotr" do
get "/Mordor/Orc"
assert_match /big smelly creatures/, last_response.body
post "/create", :content => 'really big smelly creatures', :page => 'Orc/Uruk-hai',
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
assert_equal 'http://example.org/Mordor/Orc-Uruk-hai', last_response.headers['Location']
get "/Mordor/Orc-Uruk-hai"
assert_equal 'http://example.org/Mordor/Uruk-Hai', last_response.headers['Location']
get "/Mordor/Uruk-Hai"
assert_match /really big smelly creatures/, last_response.body
end