Skip to content

Commit

Permalink
add failing tests for #5963
Browse files Browse the repository at this point in the history
it fails with ruby 2.4 onwards and passes up to ruby 2.3
  • Loading branch information
Crunch09 committed Jan 11, 2018
1 parent f77d704 commit eaac869
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/helper.rb
Expand Up @@ -149,7 +149,9 @@ def site_configuration(overrides = {})
}))
Configuration.from(full_overrides.merge({
"source" => source_dir,
}))
})).tap do |obj|
Jekyll.set_timezone(obj["timezone"]) if obj["timezone"]

This comment has been minimized.

Copy link
@parkr

parkr Jan 14, 2018

Member

We'll have to keep track of the old timezone and set it back in the teardown section of the tests in this case! I wonder if this would be better in a cucumber test?

This comment has been minimized.

Copy link
@Crunch09

Crunch09 Jan 16, 2018

Author Member

Thanks, good point! fixed in a follow-up commit

end
end

def clear_dest
Expand Down
4 changes: 4 additions & 0 deletions test/source/_dates/date_without_time.md
@@ -0,0 +1,4 @@
---
date: 2015-10-01
---
Here is the content.
4 changes: 4 additions & 0 deletions test/source/_dates/time_with_timezone.md
@@ -0,0 +1,4 @@
---
date: 2015-10-01 01:00:00 +0800
---
Here is the content.
4 changes: 4 additions & 0 deletions test/source/_dates/time_without_timezone.md
@@ -0,0 +1,4 @@
---
date: 2015-10-01 01:00:00
---
Here is the content.
39 changes: 39 additions & 0 deletions test/test_document.rb
Expand Up @@ -16,6 +16,15 @@ def setup_encoded_document(filename)
}).tap(&:read)
end

def setup_document_with_dates(filename)
site = fixture_site("collections" => ["dates"], "timezone" => "UTC")
site.process
Document.new(site.in_source_dir(File.join("_dates", filename)), {
:site => site,
:collection => site.collections["dates"],
}).tap(&:read)
end

context "a document in a collection" do
setup do
@site = fixture_site({
Expand Down Expand Up @@ -558,4 +567,34 @@ def setup_encoded_document(filename)
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

0 comments on commit eaac869

Please sign in to comment.