Skip to content

Commit

Permalink
Skip encoding customization test on ancient Rubies
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeclaghorn committed May 14, 2019
1 parent e2e8623 commit 865a660
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/jbuilder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,12 @@ class JbuilderTest < ActiveSupport::TestCase
end
end

test "respects JSON encoding customizations" do
# Active Support overrides Time#as_json for custom formatting.
# Ensure we call #to_json on the final attributes instead of JSON.dump.
result = JSON.load(Jbuilder.new { |json| json.time Time.parse("2018-05-13 11:51:00.485 -0400") }.target!)
assert_equal "2018-05-13T11:51:00.485-04:00", result["time"]
if RUBY_VERSION >= "2.2.10"
test "respects JSON encoding customizations" do
# Active Support overrides Time#as_json for custom formatting.
# Ensure we call #to_json on the final attributes instead of JSON.dump.
result = JSON.load(Jbuilder.encode { |json| json.time Time.parse("2018-05-13 11:51:00.485 -0400") })
assert_equal "2018-05-13T11:51:00.485-04:00", result["time"]
end
end
end

0 comments on commit 865a660

Please sign in to comment.