diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 227f5312..f64d874d 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -63,7 +63,7 @@ module Jekyll self.tags = Hash.new { |hash, key| hash[key] = [] } if self.limit_posts < 0 - raise ArgumentError, "Limit posts must be nil or >= 0" + raise ArgumentError, "limit_posts must not be a negative number" end end @@ -148,7 +148,7 @@ module Jekyll self.posts.sort! # limit the posts if :limit_posts option is set - unless limit_posts.zero? + if limit_posts > 0 limit = self.posts.length < limit_posts ? self.posts.length : limit_posts self.posts = self.posts[-limit, limit] end diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 09532226..0861ee93 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -68,5 +68,16 @@ class TestGeneratedSite < Test::Unit::TestCase @site = Site.new(Jekyll.configuration) end end + + should "acceptable limit post is 0" do + assert_nothing_raised ArgumentError do + clear_dest + stub(Jekyll).configuration do + Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0}) + end + + @site = Site.new(Jekyll.configuration) + end + end end end