Quick clean-up from #998.

This commit is contained in:
Parker Moore 2013-05-05 14:59:50 +02:00
parent 0edbbc1641
commit 9179f56ed7
3 changed files with 24 additions and 10 deletions

View File

@ -12,13 +12,26 @@ module Jekyll
end
def ==(other)
path = other.name.split("/")[0...-1].join("/")
otherslug = path != "" ? path + '/' + other.slug : other.slug
slug == otherslug &&
slug == post_slug(other) &&
date.year == other.date.year &&
date.month == other.date.month &&
date.day == other.date.day
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
class PostUrl < Liquid::Tag

View File

@ -48,6 +48,7 @@ class TestSite < Test::Unit::TestCase
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
end
@site = Site.new(Jekyll.configuration)
@num_invalid_posts = 2
end
should "have an empty tag hash by default" do
@ -160,20 +161,20 @@ class TestSite < Test::Unit::TestCase
should "read posts" do
@site.read_posts('')
posts = Dir[source_dir('_posts', '*')]
posts.delete_if { |post| File.directory?(post) }
assert_equal posts.size, @site.posts.size
posts = Dir[source_dir('_posts', '**', '*')]
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
assert_equal posts.size - @num_invalid_posts, @site.posts.size
end
should "deploy payload" do
clear_dest
@site.process
posts = Dir[source_dir("**", "_posts", "*")]
posts.delete_if { |post| File.directory?(post) }
posts = Dir[source_dir("**", "_posts", "**", "*")]
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
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 4, @site.categories['foo'].size
end