Merge pull request #4389 from zsyed91/refactor_page_permalink

Merge pull request 4389
This commit is contained in:
jekyllbot 2016-01-22 09:03:43 -08:00
commit c42d27e428
2 changed files with 9 additions and 3 deletions

View File

@ -63,8 +63,7 @@ module Jekyll
# #
# Returns the String permalink or nil if none has been set. # Returns the String permalink or nil if none has been set.
def permalink def permalink
return nil if data.nil? || data['permalink'].nil? data.nil? ? nil : data['permalink']
data['permalink']
end end
# The template of the permalink. # The template of the permalink.

View File

@ -8,7 +8,9 @@ class TestPage < JekyllUnitTest
end end
def do_render(page) def do_render(page)
layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")} layouts = {
"default" => Layout.new(@site, source_dir('_layouts'), "simple.html")
}
page.render(layouts, @site.site_payload) page.render(layouts, @site.site_payload)
end end
@ -206,6 +208,11 @@ class TestPage < JekyllUnitTest
assert_equal "/about/", @page.dir assert_equal "/about/", @page.dir
end end
should "return nil permalink if no permalink exists" do
@page = setup_page('')
assert_equal nil, @page.permalink
end
should "not be writable outside of destination" do should "not be writable outside of destination" do
unexpected = File.expand_path("../../../baddie.html", dest_dir) unexpected = File.expand_path("../../../baddie.html", dest_dir)
File.delete unexpected if File.exist?(unexpected) File.delete unexpected if File.exist?(unexpected)