test/test_app.rb in gollum-bibanon-1.4.3 vs test/test_app.rb in gollum-bibanon-1.4.4

- old
+ new

@@ -83,9 +83,47 @@ page = @wiki.page('D') assert_equal 'abc', page.raw_data assert_equal 'def', page.version.message end + test "redirects to create on non-existant page" do + name = "E" + get "/#{name}" + follow_redirect! + assert_equal "/create/#{name}", last_request.fullpath + assert last_response.ok? + end + + test "edit redirects to create on non-existant page" do + name = "E" + get "/edit/#{name}" + follow_redirect! + assert_equal "/create/#{name}", last_request.fullpath + assert last_response.ok? + end + + test "create redirects to page if already exists" do + name = "A" + get "/create/#{name}" + follow_redirect! + assert_equal "/#{name}", last_request.fullpath + assert last_response.ok? + end + + test "creates pages with escaped characters in title" do + post "/create", :content => 'abc', :page => 'Title with spaces', + :format => 'markdown', :message => 'foo' + 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 "guards against creation of existing page" do name = "A" post "/create", :content => 'abc', :page => name, :format => 'markdown', :message => 'def' assert last_response.ok?