Merge pull request #1078 from maul-esel/fix-num-category

Fix number category
This commit is contained in:
Parker Moore 2013-05-12 02:52:39 -07:00
commit f9502dc9f5
5 changed files with 16 additions and 3 deletions

View File

@ -76,7 +76,7 @@ module Jekyll
def populate_categories
if self.categories.empty?
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s.downcase}
end
self.categories.flatten!
end

View File

@ -0,0 +1,7 @@
---
layout: default
title: Number Category in YAML
category: 2013
---
Please make me pass

View File

@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
end
should "ensure post count is as expected" do
assert_equal 33, @site.posts.size
assert_equal 34, @site.posts.size
end
should "insert site.posts into the index" do

View File

@ -422,6 +422,12 @@ class TestPost < Test::Unit::TestCase
post = setup_post("2009-01-27-empty-categories.textile")
assert_equal [], post.categories
end
should "recognize number category in yaml" do
post = setup_post("2013-05-10-number-category.textile")
assert post.categories.include?('2013')
assert !post.categories.include?(2013)
end
should "recognize tag in yaml" do
post = setup_post("2009-05-18-tag.textile")

View File

@ -172,7 +172,7 @@ class TestSite < Test::Unit::TestCase
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
categories = %w(2013 bar baz category foo z_category publish_test win).sort
assert_equal posts.size - @num_invalid_posts, @site.posts.size
assert_equal categories, @site.categories.keys.sort