diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 91cadc04..eb9c5f97 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -91,6 +91,9 @@ module Precious end # path is set to name if path is nil. + # if path is 'a/b' and a and b are dirs, then + # path must have a trailing slash 'a/b/' or + # extract_path will trim path to 'a' # name, path, version def wiki_page( name, path = nil, version = nil) path = name if path.nil? @@ -193,7 +196,7 @@ module Precious begin wiki.write_page(name, format, params[:content], commit_message) page = wiki.page(name) - redirect to("/#{page.escaped_url_path}") + redirect to("/#{page.escaped_url_path}") unless page.nil? rescue Gollum::DuplicatePageError => e @message = "Duplicate page: #{e.message}" mustache :error diff --git a/test/test_app.rb b/test/test_app.rb index d76eab1e..b452c1e3 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -142,6 +142,24 @@ context "Frontend" do assert last_response.ok? end + test "page create and edit with dash" do + page = 'c-d-e' + path = 'a/b/' # path must end with / + + post '/create', :content => 'create_msg', :page => page, + :path => path, :format => 'markdown', :message => '' + assert_equal 'create_msg', @wiki.paged(page, path).raw_data + + # must clear or create_msg will be returned + @wiki.clear_cache + + # post '/edit' fails. post '/edit/' works. + post '/edit/', :content => 'edit_msg', + :page => page, :path => path, :message => '' + wpage = @wiki.paged(page, path) + assert_equal 'edit_msg', @wiki.paged(page, path).raw_data + end + test "guards against creation of existing page" do name = "A" post "/create", :content => 'abc', :page => name,