Clean up code #1104
This commit is contained in:
parent
94756340cd
commit
0f52f15cc2
|
@ -63,7 +63,7 @@ module Jekyll
|
||||||
self.tags = Hash.new { |hash, key| hash[key] = [] }
|
self.tags = Hash.new { |hash, key| hash[key] = [] }
|
||||||
|
|
||||||
if self.limit_posts < 0
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ module Jekyll
|
||||||
self.posts.sort!
|
self.posts.sort!
|
||||||
|
|
||||||
# limit the posts if :limit_posts option is set
|
# 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
|
limit = self.posts.length < limit_posts ? self.posts.length : limit_posts
|
||||||
self.posts = self.posts[-limit, limit]
|
self.posts = self.posts[-limit, limit]
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,5 +68,16 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||||
@site = Site.new(Jekyll.configuration)
|
@site = Site.new(Jekyll.configuration)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue