Remove extra OR condition since a missing hash key will return a nil anyway. Added a test to catch this nil condition since it was missing to begin with. Reduced line length in test_page.rb
This commit is contained in:
parent
b3ddd985a4
commit
4ecdf6ce10
|
@ -63,8 +63,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the String permalink or nil if none has been set.
|
||||
def permalink
|
||||
return nil if data.nil? || data['permalink'].nil?
|
||||
data['permalink']
|
||||
data.nil? ? nil : data['permalink']
|
||||
end
|
||||
|
||||
# The template of the permalink.
|
||||
|
|
|
@ -8,7 +8,9 @@ class TestPage < JekyllUnitTest
|
|||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -206,6 +208,11 @@ class TestPage < JekyllUnitTest
|
|||
assert_equal "/about/", @page.dir
|
||||
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
|
||||
unexpected = File.expand_path("../../../baddie.html", dest_dir)
|
||||
File.delete unexpected if File.exist?(unexpected)
|
||||
|
|
Loading…
Reference in New Issue