mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Ensuring that layout is only set to the default value if layout is not specified
This commit is contained in:
6
test/source/_posts/2013-01-12-nil-layout.textile
Normal file
6
test/source/_posts/2013-01-12-nil-layout.textile
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
layout: nil
|
||||
title: No layout
|
||||
---
|
||||
|
||||
This post has no layout.
|
||||
5
test/source/_posts/2013-01-12-no-layout.textile
Normal file
5
test/source/_posts/2013-01-12-no-layout.textile
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: I have no layout
|
||||
---
|
||||
|
||||
This post will be rendered with the "post" layout.
|
||||
@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "ensure post count is as expected" do
|
||||
assert_equal 28, @site.posts.size
|
||||
assert_equal 30, @site.posts.size
|
||||
end
|
||||
|
||||
should "insert site.posts into the index" do
|
||||
|
||||
@@ -66,6 +66,26 @@ class TestPage < Test::Unit::TestCase
|
||||
assert_equal "/about/", @page.dir
|
||||
end
|
||||
end
|
||||
|
||||
context "with unspecified layout" do
|
||||
setup do
|
||||
@page = setup_page('contacts.html')
|
||||
end
|
||||
|
||||
should "default to 'post' layout" do
|
||||
assert_equal "page", @page.data["layout"]
|
||||
end
|
||||
end
|
||||
|
||||
context "with specified layout of nil" do
|
||||
setup do
|
||||
@page = setup_page('sitemap.xml')
|
||||
end
|
||||
|
||||
should "layout of nil is respected" do
|
||||
assert_equal "nil", @page.data["layout"]
|
||||
end
|
||||
end
|
||||
|
||||
context "rendering" do
|
||||
setup do
|
||||
|
||||
@@ -95,7 +95,7 @@ class TestPost < Test::Unit::TestCase
|
||||
should "consume the embedded dashes" do
|
||||
@post.read_yaml(@source, @real_file)
|
||||
|
||||
assert_equal({"title" => "Foo --- Bar"}, @post.data)
|
||||
assert_equal({"title" => "Foo --- Bar", "layout" => "post"}, @post.data)
|
||||
assert_equal "Triple the fun!", @post.content
|
||||
end
|
||||
end
|
||||
@@ -128,6 +128,30 @@ class TestPost < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "with unspecified layout" do
|
||||
setup do
|
||||
file = '2013-01-12-no-layout.textile'
|
||||
@post = setup_post(file)
|
||||
@post.process(file)
|
||||
end
|
||||
|
||||
should "default to 'post' layout" do
|
||||
assert_equal "post", @post.data["layout"]
|
||||
end
|
||||
end
|
||||
|
||||
context "with specified layout of nil" do
|
||||
setup do
|
||||
file = '2013-01-12-nil-layout.textile'
|
||||
@post = setup_post(file)
|
||||
@post.process(file)
|
||||
end
|
||||
|
||||
should "layout of nil is respected" do
|
||||
assert_equal "nil", @post.data["layout"]
|
||||
end
|
||||
end
|
||||
|
||||
context "with unspecified (date) style and categories" do
|
||||
setup do
|
||||
@post.categories << "food"
|
||||
|
||||
Reference in New Issue
Block a user