Sort pages by name by default

The order that files are returned differs across operating systems, so
ensure that they're being sorted after the fact.
This commit is contained in:
Aidan Feldman 2013-12-19 01:02:25 -05:00
parent 12a55b86ac
commit 3c1d45f45f
2 changed files with 10 additions and 0 deletions

View File

@ -175,6 +175,8 @@ module Jekyll
static_files << StaticFile.new(self, self.source, dir, f) static_files << StaticFile.new(self, self.source, dir, f)
end end
end end
pages.sort_by!(&:name)
end end
# Read all the files in <source>/<dir>/_posts and create a new Post # Read all the files in <source>/<dir>/_posts and create a new Post

View File

@ -154,6 +154,14 @@ class TestSite < Test::Unit::TestCase
assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority} assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority}
end end
should "sort pages in a consistent way" do
# The order that files are returned differs across operating systems, so ensure that they're being sorted after the fact.
stub.proxy(Dir).entries { |entries| entries.reverse }
@site.process
sorted_pages = %w(.htaccess about.html bar.html contacts.html deal.with.dots.html foo.md index.html index.html sitemap.xml symlinked-file)
assert_equal sorted_pages, @site.pages.map(&:name)
end
should "read layouts" do should "read layouts" do
@site.read_layouts @site.read_layouts
assert_equal ["default", "simple", "post/simple"].sort, @site.layouts.keys.sort assert_equal ["default", "simple", "post/simple"].sort, @site.layouts.keys.sort