mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-06 03:01:43 -04:00
Fix timezone incosistencies between different ruby version (#6697)
Merge pull request 6697
This commit is contained in:
committed by
jekyllbot
parent
c9d2da8722
commit
cf5c689d94
@@ -16,6 +16,19 @@ class TestDocument < JekyllUnitTest
|
||||
}).tap(&:read)
|
||||
end
|
||||
|
||||
def setup_document_with_dates(filename)
|
||||
site = fixture_site("collections" => ["dates"])
|
||||
site.process
|
||||
docs = nil
|
||||
with_env("TZ", "UTC") do
|
||||
docs = Document.new(site.in_source_dir(File.join("_dates", filename)), {
|
||||
:site => site,
|
||||
:collection => site.collections["dates"],
|
||||
}).tap(&:read)
|
||||
end
|
||||
docs
|
||||
end
|
||||
|
||||
context "a document in a collection" do
|
||||
setup do
|
||||
@site = fixture_site({
|
||||
@@ -558,4 +571,34 @@ class TestDocument < JekyllUnitTest
|
||||
Jekyll::Renderer.new(@document.site, @document).render_document
|
||||
end
|
||||
end
|
||||
|
||||
context "a document with a date with timezone" do
|
||||
setup do
|
||||
@document = setup_document_with_dates "time_with_timezone.md"
|
||||
end
|
||||
|
||||
should "have the expected date" do
|
||||
assert_equal "2015/09/30", @document.data["date"].strftime("%Y/%m/%d")
|
||||
end
|
||||
end
|
||||
|
||||
context "a document with a date with time but without timezone" do
|
||||
setup do
|
||||
@document = setup_document_with_dates "time_without_timezone.md"
|
||||
end
|
||||
|
||||
should "have the expected date" do
|
||||
assert_equal "2015/10/01", @document.data["date"].strftime("%Y/%m/%d")
|
||||
end
|
||||
end
|
||||
|
||||
context "a document with a date without time" do
|
||||
setup do
|
||||
@document = setup_document_with_dates "date_without_time.md"
|
||||
end
|
||||
|
||||
should "have the expected date" do
|
||||
assert_equal "2015/10/01", @document.data["date"].strftime("%Y/%m/%d")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user