aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/json
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/json')
-rw-r--r--activesupport/test/json/encoding_test.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 1cbd472a99..290232988a 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -35,10 +35,19 @@ class TestJSONEncoding < Test::Unit::TestCase
TimeTests = [[ Time.utc(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
DateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
+ StandardDateTests = [[ Date.new(2005,2,1), %("2005-02-01") ]]
+ StandardTimeTests = [[ Time.utc(2005,2,1,15,15,10), %("2005-02-01T15:15:10Z") ]]
+ StandardDateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005-02-01T15:15:10+00:00") ]]
+
constants.grep(/Tests$/).each do |class_tests|
- define_method("test_#{class_tests[0..-6].downcase}") do
- self.class.const_get(class_tests).each do |pair|
- assert_equal pair.last, pair.first.to_json
+ define_method("test_#{class_tests[0..-6].underscore}") do
+ begin
+ ActiveSupport.use_standard_json_time_format = class_tests =~ /^Standard/
+ self.class.const_get(class_tests).each do |pair|
+ assert_equal pair.last, pair.first.to_json
+ end
+ ensure
+ ActiveSupport.use_standard_json_time_format = false
end
end
end