Quick clean-up from #998.
This commit is contained in:
parent
0edbbc1641
commit
9179f56ed7
|
@ -12,13 +12,26 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
path = other.name.split("/")[0...-1].join("/")
|
slug == post_slug(other) &&
|
||||||
otherslug = path != "" ? path + '/' + other.slug : other.slug
|
|
||||||
slug == otherslug &&
|
|
||||||
date.year == other.date.year &&
|
date.year == other.date.year &&
|
||||||
date.month == other.date.month &&
|
date.month == other.date.month &&
|
||||||
date.day == other.date.day
|
date.day == other.date.day
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Construct the directory-aware post slug for a Jekyll::Post
|
||||||
|
#
|
||||||
|
# other - the Jekyll::Post
|
||||||
|
#
|
||||||
|
# Returns the post slug with the subdirectory (relative to _posts)
|
||||||
|
def post_slug(other)
|
||||||
|
path = other.name.split("/")[0...-1].join("/")
|
||||||
|
if path.nil? || path == ""
|
||||||
|
other.slug
|
||||||
|
else
|
||||||
|
path + '/' + other.slug
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class PostUrl < Liquid::Tag
|
class PostUrl < Liquid::Tag
|
||||||
|
|
|
@ -5,4 +5,4 @@ title: Nested
|
||||||
|
|
||||||
url: {{ page.url }}
|
url: {{ page.url }}
|
||||||
date: {{ page.date }}
|
date: {{ page.date }}
|
||||||
id: {{ page.id }}
|
id: {{ page.id }}
|
||||||
|
|
|
@ -48,6 +48,7 @@ class TestSite < Test::Unit::TestCase
|
||||||
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
|
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
|
||||||
end
|
end
|
||||||
@site = Site.new(Jekyll.configuration)
|
@site = Site.new(Jekyll.configuration)
|
||||||
|
@num_invalid_posts = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an empty tag hash by default" do
|
should "have an empty tag hash by default" do
|
||||||
|
@ -160,20 +161,20 @@ class TestSite < Test::Unit::TestCase
|
||||||
|
|
||||||
should "read posts" do
|
should "read posts" do
|
||||||
@site.read_posts('')
|
@site.read_posts('')
|
||||||
posts = Dir[source_dir('_posts', '*')]
|
posts = Dir[source_dir('_posts', '**', '*')]
|
||||||
posts.delete_if { |post| File.directory?(post) }
|
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
|
||||||
assert_equal posts.size, @site.posts.size
|
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||||
end
|
end
|
||||||
|
|
||||||
should "deploy payload" do
|
should "deploy payload" do
|
||||||
clear_dest
|
clear_dest
|
||||||
@site.process
|
@site.process
|
||||||
|
|
||||||
posts = Dir[source_dir("**", "_posts", "*")]
|
posts = Dir[source_dir("**", "_posts", "**", "*")]
|
||||||
posts.delete_if { |post| File.directory?(post) }
|
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
|
||||||
categories = %w(bar baz category foo z_category publish_test win).sort
|
categories = %w(bar baz category foo z_category publish_test win).sort
|
||||||
|
|
||||||
assert_equal posts.size + 1, @site.posts.size
|
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||||
assert_equal categories, @site.categories.keys.sort
|
assert_equal categories, @site.categories.keys.sort
|
||||||
assert_equal 4, @site.categories['foo'].size
|
assert_equal 4, @site.categories['foo'].size
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue