1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

test json decoding with time parsing disabled with all backends and respect ActiveSupport.parse_json_times when converting to yaml

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Diego Carrion 2011-03-09 20:27:29 -03:00 committed by Santiago Pastorino
parent 450f7cf01b
commit 7004434ad8
2 changed files with 7 additions and 7 deletions

View file

@ -70,10 +70,12 @@ module ActiveSupport
left_pos.each_with_index do |left, i|
scanner.pos = left.succ
chunk = scanner.peek(right_pos[i] - scanner.pos + 1)
if ActiveSupport.parse_json_times
# overwrite the quotes found around the dates with spaces
while times.size > 0 && times[0] <= right_pos[i]
chunk.insert(times.shift - scanner.pos - 1, '! ')
end
end
chunk.gsub!(/\\([\\\/]|u[[:xdigit:]]{4})/) do
ustr = $1
if ustr.start_with?('u')

View file

@ -72,13 +72,11 @@ class TestJSONDecoding < ActiveSupport::TestCase
end
end
end
end
if backends.include?("JSONGem")
test "json decodes time json with time parsing disabled" do
test "json decodes time json with time parsing disabled with the #{backend} backend" do
ActiveSupport.parse_json_times = false
expected = {"a" => "2007-01-01 01:12:34 Z"}
ActiveSupport::JSON.with_backend "JSONGem" do
ActiveSupport::JSON.with_backend backend do
assert_equal expected, ActiveSupport::JSON.decode(%({"a": "2007-01-01 01:12:34 Z"}))
end
end