test/test_site.rb in gollum-site-0.1.9 vs test/test_site.rb in gollum-site-0.1.10
- old
+ new
@@ -52,10 +52,13 @@
end
context "Preview" do
setup do
@path = testpath("examples/uncommitted_untracked_changes")
+ @repo = Grit::Repo.init(@path)
+ @repo.add("#{@path}")
+ @repo.commit_all("Initial commit")
# Add untracked file
File.open(@path + '/Foo.md', 'w') { |f| f.write("Bar") }
# Modify tracked file
File.open(@path + '/Home.md', 'w') { |f| f.write("Hello World\nHello World") }
@site = Gollum::Site.new(@path, {
@@ -76,20 +79,82 @@
test "working site Home.html content is uncommitted version" do
data = IO.read(::File.join(@site.output_path, "Home.html"))
assert_equal("<p>Hello World\nHello World</p>", data)
end
- test "one item can be updated" do
- File.open(@path + '/Foo.md', 'w') { |f| f.write("Baz") }
- @site.update_working_item('Foo.md')
- data = IO.read(::File.join(@site.output_path, "Foo.html"))
- assert_equal("<p>Baz</p>", data)
- end
-
teardown do
# Remove untracked file
FileUtils.rm(@path + '/Foo.md')
# Reset tracked file
File.open(@path + '/Home.md', 'w') { |f| f.write("Hello World\n") }
+ FileUtils.rm_r(@site.output_path)
+ FileUtils.rm_r(@path + '/.git')
+ end
+end
+
+context "Sanitization" do
+ setup do
+ @path = Dir.mktmpdir('gollumsite')
+ @repo = Grit::Repo.init(@path)
+ @repo.add("#{@path}")
+ @repo.commit_all("Initial commit")
+ # protocols
+ File.open(@path + '/Home.md', 'w') { |f| f.write("<a href=\"irc://irc.freenode.net/foo\">Hello World</a>") }
+ # elements
+ File.open(@path + '/Foo.md', 'w') { |f| f.write("<embed src=\"foo.html\">") }
+ @site = Gollum::Site.new(@path, {
+ :output_path => testpath("examples/site"),
+ :version => :working,
+ :allow_protocols => ['irc'],
+ :allow_elements => ['embed'],
+ :allow_attributes => ['src']
+ })
+ @site.generate()
+ end
+
+ test "link with irc protocol" do
+ data = IO.read(::File.join(@site.output_path, "Home.html"))
+ assert_equal("<p><a href=\"irc://irc.freenode.net/foo\">Hello World</a></p>", data)
+ end
+
+ test "embed with src" do
+ data = IO.read(::File.join(@site.output_path, "Foo.html"))
+ assert_equal("<p><embed src=\"foo.html\"></embed></p>", data)
+ end
+
+ teardown do
+ FileUtils.rm_r(@site.output_path)
+ FileUtils.rm_r(@path)
+ end
+
+end
+
+context "Sidebar and Footer" do
+ setup do
+ @path = testpath("examples/test_footer_and_sidebar.git")
+
+ @site = Gollum::Site.new(@path, {
+ :output_path => testpath("examples/site"),
+ :version => "master"
+ })
+ @site.generate()
+ end
+
+ test "Sidebar and Footer files are ignored" do
+ assert !File.exists?(@site.output_path + '_Footer.html')
+ assert !File.exists?(@site.output_path + '_Sidebar.html')
+ end
+
+ test "Footer is rendered in _Layout" do
+ data = IO.read(::File.join(@site.output_path, "footer.html"))
+ assert_equal "<p>hello</p>\n", data
+ end
+
+ test "Sidebar is rendered in _Layout" do
+ data = IO.read(::File.join(@site.output_path, "sidebar.html"))
+ assert_equal "<p>world</p>\n", data
+ end
+
+ teardown do
FileUtils.rm_r(@site.output_path)
end
end