Clean up tests. Remove templates
This commit is contained in:
+39
-39
@@ -16,8 +16,8 @@ context "Frontend" do
|
||||
end
|
||||
|
||||
test "urls transform unicode" do
|
||||
header = '_Header'
|
||||
footer = '_Footer'
|
||||
header = '_Header'
|
||||
footer = '_Footer'
|
||||
sidebar = '_Sidebar'
|
||||
|
||||
# header, footer, and sidebar must be preserved
|
||||
@@ -79,7 +79,7 @@ context "Frontend" do
|
||||
get page
|
||||
|
||||
expected = "<h2><a class=\"anchor\" id=\"#{text}\" href=\"##{text}\"><i class=\"fa fa-link\"></i></a>#{text}</h2>"
|
||||
actual = nfd(last_response.body)
|
||||
actual = nfd(last_response.body)
|
||||
|
||||
assert_match /#{expected}/, actual
|
||||
end
|
||||
@@ -108,7 +108,7 @@ context "Frontend" do
|
||||
test "edits page" do
|
||||
page_1 = @wiki.page('A')
|
||||
post "/edit/A", :content => 'abc', :page => 'A',
|
||||
:format => page_1.format, :message => 'def'
|
||||
:format => page_1.format, :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@@ -122,7 +122,7 @@ context "Frontend" do
|
||||
test "edit page with empty message" do
|
||||
page_1 = @wiki.page('A')
|
||||
post "/edit/A", :content => 'abc', :page => 'A',
|
||||
:format => page_1.format
|
||||
:format => page_1.format
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@@ -136,39 +136,39 @@ context "Frontend" do
|
||||
test "edit page with slash" do
|
||||
page_1 = @wiki.page('A')
|
||||
post "/edit/A", :content => 'abc', :page => 'A', :path => '/////',
|
||||
:format => page_1.format, :message => 'def'
|
||||
:format => page_1.format, :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test "edits page header footer and sidebar" do
|
||||
commits = @wiki.repo.commits('master').size
|
||||
page_1 = @wiki.page('A')
|
||||
commits = @wiki.repo.commits('master').size
|
||||
page_1 = @wiki.page('A')
|
||||
header_1 = page_1.header
|
||||
foot_1 = page_1.footer
|
||||
side_1 = page_1.sidebar
|
||||
foot_1 = page_1.footer
|
||||
side_1 = page_1.sidebar
|
||||
|
||||
post "/edit/A", :header => 'header',
|
||||
:footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
|
||||
:footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
|
||||
follow_redirect!
|
||||
assert_equal "/A", last_request.fullpath
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
page_2 = @wiki.page(page_1.name)
|
||||
page_2 = @wiki.page(page_1.name)
|
||||
header_2 = page_2.header
|
||||
foot_2 = page_2.footer
|
||||
side_2 = page_2.sidebar
|
||||
foot_2 = page_2.footer
|
||||
side_2 = page_2.sidebar
|
||||
assert_equal page_1.raw_data, page_2.raw_data
|
||||
|
||||
assert_equal 'header', header_2.raw_data
|
||||
assert_equal 'footer', foot_2.raw_data
|
||||
assert_equal 'def', foot_2.version.message
|
||||
assert_equal 'def', foot_2.version.message
|
||||
assert_not_equal foot_1.version.sha, foot_2.version.sha
|
||||
assert_not_equal header_1.version.sha, header_2.version.sha
|
||||
|
||||
assert_equal 'sidebar', side_2.raw_data
|
||||
assert_equal 'def', side_2.version.message
|
||||
assert_equal 'def', side_2.version.message
|
||||
assert_not_equal side_1.version.sha, side_2.version.sha
|
||||
assert_equal commits+1, @wiki.repo.commits('master').size
|
||||
end
|
||||
@@ -248,7 +248,7 @@ context "Frontend" do
|
||||
|
||||
test "creates page" do
|
||||
post "/create", :content => 'abc', :page => "D",
|
||||
:format => 'markdown', :message => 'def'
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@@ -259,7 +259,7 @@ context "Frontend" do
|
||||
|
||||
test "creates pages with escaped characters in title" do
|
||||
post "/create", :content => 'abc', :page => 'Title with spaces',
|
||||
:format => 'markdown', :message => 'foo'
|
||||
: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
|
||||
@@ -283,7 +283,7 @@ context "Frontend" do
|
||||
|
||||
test "accessing redirectory redirects to index page" do
|
||||
post "/create", :content => 'abc', :page => 'Home', :path => '/foo/',
|
||||
:format => 'markdown', :message => 'foo'
|
||||
:format => 'markdown', :message => 'foo'
|
||||
|
||||
assert_equal "http://example.org/foo/Home", last_response.headers['Location']
|
||||
|
||||
@@ -308,7 +308,7 @@ context "Frontend" do
|
||||
end
|
||||
|
||||
test "create sets the correct path for a relative path subdirectory" do
|
||||
dir = "foodir"
|
||||
dir = "foodir"
|
||||
name = "#{dir}/bar"
|
||||
get "/create/#{name}"
|
||||
assert_match(/\/#{dir}/, last_response.body)
|
||||
@@ -316,14 +316,14 @@ context "Frontend" do
|
||||
end
|
||||
|
||||
test "create sets the correct path for a relative path subdirectory with the page file directory set" do
|
||||
Precious::App.set(:wiki_options, {:page_file_dir => "foo"})
|
||||
dir = "bardir"
|
||||
Precious::App.set(:wiki_options, { :page_file_dir => "foo" })
|
||||
dir = "bardir"
|
||||
name = "#{dir}/baz"
|
||||
get "/create/foo/#{name}"
|
||||
assert_match(/\/#{dir}/, last_response.body)
|
||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||
# reset page_file_dir
|
||||
Precious::App.set(:wiki_options, {:page_file_dir => nil})
|
||||
Precious::App.set(:wiki_options, { :page_file_dir => nil })
|
||||
end
|
||||
|
||||
test "edit returns nil for non-existant page" do
|
||||
@@ -331,7 +331,7 @@ context "Frontend" do
|
||||
page = 'not-real-page'
|
||||
path = '/'
|
||||
post '/edit/', :content => 'edit_msg',
|
||||
:page => page, :path => path, :message => ''
|
||||
:page => page, :path => path, :message => ''
|
||||
page_e = @wiki.paged(page, path)
|
||||
assert_equal nil, page_e
|
||||
end
|
||||
@@ -341,7 +341,7 @@ context "Frontend" do
|
||||
path = 'a/b/' # path must end with /
|
||||
|
||||
post '/create', :content => 'create_msg', :page => page,
|
||||
:path => path, :format => 'markdown', :message => ''
|
||||
:path => path, :format => 'markdown', :message => ''
|
||||
page_c = @wiki.paged(page, path)
|
||||
assert_equal 'create_msg', page_c.raw_data
|
||||
|
||||
@@ -350,7 +350,7 @@ context "Frontend" do
|
||||
|
||||
# post '/edit' fails. post '/edit/' works.
|
||||
post '/edit/', :content => 'edit_msg',
|
||||
:page => page, :path => path, :message => ''
|
||||
:page => page, :path => path, :message => ''
|
||||
page_e = @wiki.paged(page, path)
|
||||
assert_equal 'edit_msg', page_e.raw_data
|
||||
|
||||
@@ -369,7 +369,7 @@ context "Frontend" do
|
||||
test "guards against creation of existing page" do
|
||||
name = "A"
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'def'
|
||||
:format => 'markdown', :message => 'def'
|
||||
|
||||
assert last_response.ok?
|
||||
|
||||
@@ -381,7 +381,7 @@ context "Frontend" do
|
||||
test "delete a page" do
|
||||
name = "deleteme"
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'foo'
|
||||
:format => 'markdown', :message => 'foo'
|
||||
page = @wiki.page(name)
|
||||
assert_equal 'abc', page.raw_data
|
||||
|
||||
@@ -474,7 +474,7 @@ context "Frontend" do
|
||||
page1 = @wiki.page('A')
|
||||
|
||||
gollum_author = { :name => 'ghi', :email => 'jkl' }
|
||||
session = { 'gollum.author' => gollum_author }
|
||||
session = { 'gollum.author' => gollum_author }
|
||||
|
||||
post "/edit/A", { :content => 'abc', :page => 'A', :format => page1.format, :message => 'def' }, { 'rack.session' => session }
|
||||
follow_redirect!
|
||||
@@ -514,12 +514,12 @@ context "Frontend" do
|
||||
|
||||
test "show edit page with header and footer and sidebar of multibyte" do
|
||||
post "/create",
|
||||
:content => 'りんご',
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||
:content => 'りんご',
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||
|
||||
post "/edit/Multibyte",
|
||||
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||
|
||||
get "edit/Multibyte"
|
||||
|
||||
@@ -627,7 +627,7 @@ context "Frontend with lotr" do
|
||||
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||
page = 'path'
|
||||
post "/create", :content => '123', :page => page,
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
# should be wiki/Mordor/path
|
||||
assert_equal 'http://example.org/Mordor/' + page, last_response.headers['Location']
|
||||
get '/Mordor/' + page
|
||||
@@ -639,7 +639,7 @@ context "Frontend with lotr" do
|
||||
|
||||
test "create pages within sub-directories using page file dir" do
|
||||
post "/create", :content => 'one two', :page => 'base',
|
||||
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/wiki/Mordor/base', last_response.headers['Location']
|
||||
get "/wiki/Mordor/base"
|
||||
|
||||
@@ -649,13 +649,13 @@ context "Frontend with lotr" do
|
||||
|
||||
test "create pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
get "/Mordor/Orc"
|
||||
assert_match /big smelly creatures/, last_response.body
|
||||
|
||||
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
|
||||
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
|
||||
@@ -663,12 +663,12 @@ context "Frontend with lotr" do
|
||||
|
||||
test "edit pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
|
||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
||||
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
|
||||
get "/Mordor/Orc"
|
||||
|
||||
Reference in New Issue
Block a user