Clean up tests. Remove templates

This commit is contained in:
bootstraponline
2014-04-05 12:46:41 -04:00
parent a7a1c4f81e
commit 452d825e66
6 changed files with 66 additions and 156 deletions
-92
View File
@@ -1,92 +0,0 @@
<style>
div.frame {
margin: 1em 0;
}
div.frame div {
display: inline-block;
border: 1px solid #aaa;
padding: 4px;
}
div div p {
font-size: 9px;
margin: 0;
padding: 4px 0 0 0;
text-align: center;
}
.float-left {
float: left;
padding-right: 1em;
}
.float-right {
float: right;
padding-left: 1em;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
</style>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante. <img src="http://www.google.com/images/nav_logo8.png" style="max-width: 16px;" /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante.
<div class="frame float-left">
<div>
<img src="http://www.google.com/images/nav_logo8.png" style="max-width: 100px;" />
<p>Google</p>
</div>
</div>
Fusce ullamcorper orci enim. Duis lectus elit, convallis ac convallis sit amet, euismod imperdiet dolor. Nunc egestas nisi quis magna feugiat vitae fringilla elit fermentum.
<div class="frame float-right">
<div>
<img src="http://www.google.com/images/nav_logo8.png" style="max-width: 100px;" />
<p>Google</p>
</div>
</div>
Vivamus sollicitudin dolor sit amet elit mollis ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit eros felis. Nunc non enim at dolor malesuada pellentesque a quis nibh. Aliquam sit amet pretium ante.<p>
<div class="frame align-left">
<div>
<img src="http://www.google.com/images/nav_logo8.png" />
<p>Google</p>
</div>
</div>
<p>Phasellus porta dignissim leo vel hendrerit. Nulla pellentesque nisi ac nunc malesuada aliquam. Nullam et cursus augue. Sed rhoncus pharetra odio, vel dictum diam facilisis et. Etiam molestie justo ut purus elementum rhoncus. Fusce nec augue lectus. Proin a nisl ac lectus facilisis tempus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent blandit tempus libero, in interdum odio dignissim quis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec quis arcu a metus tincidunt scelerisque eget sed mauris. Nullam pellentesque faucibus sodales. Integer ullamcorper enim id nibh tempor ultricies.</p>
<div class="frame align-center">
<div>
<img src="http://www.google.com/images/nav_logo8.png" />
<p>Google</p>
</div>
</div>
<p>Phasellus porta dignissim leo vel hendrerit. Nulla pellentesque nisi ac nunc malesuada aliquam. Nullam et cursus augue. Sed rhoncus pharetra odio, vel dictum diam facilisis et. Etiam molestie justo ut purus elementum rhoncus. Fusce nec augue lectus. Proin a nisl ac lectus facilisis tempus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent blandit tempus libero, in interdum odio dignissim quis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec quis arcu a metus tincidunt scelerisque eget sed mauris. Nullam pellentesque faucibus sodales. Integer ullamcorper enim id nibh tempor ultricies.</p>
<p>
<div class="frame align-right">
<div>
<img src="http://www.google.com/images/nav_logo8.png" />
</div>
</div>
</p>
<p>Phasellus porta dignissim leo vel hendrerit. Nulla pellentesque nisi ac nunc malesuada aliquam. Nullam et cursus augue. Sed rhoncus pharetra odio, vel dictum diam facilisis et. Etiam molestie justo ut purus elementum rhoncus. Fusce nec augue lectus. Proin a nisl ac lectus facilisis tempus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent blandit tempus libero, in interdum odio dignissim quis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec quis arcu a metus tincidunt scelerisque eget sed mauris. Nullam pellentesque faucibus sodales. Integer ullamcorper enim id nibh tempor ultricies. <div class="frame align-right">
<div>
<img src="http://www.google.com/images/nav_logo8.png" />
</div>
</div> Phasellus porta dignissim leo vel hendrerit. Nulla pellentesque nisi ac nunc malesuada aliquam. Nullam et cursus augue. Sed rhoncus pharetra odio, vel dictum diam facilisis et. Etiam molestie justo ut purus elementum rhoncus. Fusce nec augue lectus. Proin a nisl ac lectus facilisis tempus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent blandit tempus libero, in interdum odio dignissim quis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec quis arcu a metus tincidunt scelerisque eget sed mauris. Nullam pellentesque faucibus sodales. Integer ullamcorper enim id nibh tempor ultricies.</p>
-10
View File
@@ -1,10 +0,0 @@
class WikiFactory
def self.create p
examples = testpath "examples"
path = File.join(examples, "test.git")
FileUtils.cp_r File.join(examples, "empty.git"), path, :remove_destination => true
Gollum::Wiki.default_options = {:universal_toc => false}
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
Gollum::Wiki.new(@path), @path, cleanup
end
end
+18 -6
View File
@@ -26,7 +26,7 @@ $METADATA = false
# Make sure we're in the test dir, the tests expect that to be the current
# directory.
TEST_DIR = File.join(File.dirname(__FILE__), *%w[.])
TEST_DIR = File.join(File.dirname(__FILE__), *%w[.])
def testpath(path)
File.join(TEST_DIR, path)
@@ -64,14 +64,26 @@ def context(*args, &block)
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
def self.test(name, &block)
define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
define_method("test_#{name.gsub(/\W/, '_')}", &block) if block
end
def self.xtest(*args)
end
def self.setup(&block)
define_method(:setup, &block)
end
def self.teardown(&block)
define_method(:teardown, &block)
end
def self.xtest(*args) end
def self.setup(&block) define_method(:setup, &block) end
def self.teardown(&block) define_method(:teardown, &block) end
end
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
(
class << klass;
self
end).send(:define_method, :name) { name.gsub(/\W/, '_') }
$contexts << klass
klass.class_eval &block
end
$contexts = []
+39 -39
View File
@@ -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"
+1 -1
View File
@@ -5,7 +5,7 @@ require File.expand_path '../../lib/gollum/views/page', __FILE__
context "Precious::Views::Page" do
setup do
examples = testpath "examples"
@path = File.join(examples, "test.git")
@path = File.join(examples, "test.git")
FileUtils.cp_r File.join(examples, "empty.git"), @path, :remove_destination => true
@wiki = Gollum::Wiki.new(@path)
end
+8 -8
View File
@@ -38,7 +38,7 @@ context "Frontend Unicode support" do
test "creates korean page which contains korean content" do
post "/create", :content => '한글 text', :page => "k",
:format => 'markdown', :message => 'def'
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@@ -49,7 +49,7 @@ context "Frontend Unicode support" do
test "heavy use 1" do
post "/create", :content => '한글 text', :page => "PG",
:format => 'markdown', :message => 'def'
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@@ -62,36 +62,36 @@ context "Frontend Unicode support" do
assert last_response.ok?
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('PG')
page = @wiki.page('PG')
assert_equal '바뀐 text', utf8(page.raw_data)
assert_equal 'ghi', page.version.message
end
test "heavy use 2" do
post "/create", :content => '한글 text', :page => "k",
:format => 'markdown', :message => 'def'
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {})
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('k')
page = @wiki.page('k')
assert_equal '다른 text', utf8(page.raw_data)
post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
:format => 'markdown', :message => 'ghi'
:format => 'markdown', :message => 'ghi'
follow_redirect!
assert last_response.ok?
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('k')
page = @wiki.page('k')
assert_equal '바뀐 text', utf8(page.raw_data)
assert_equal 'ghi', page.version.message
end
test 'transliteration' do
# TODO: Remove to_url once write_page changes are merged.
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' } )
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' })
page = @wiki.page('eeeee')
assert_equal '한글 text', utf8(page.raw_data)
end