aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-07-29 01:35:49 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-07-29 01:35:49 -0700
commit540bc3d9b16d33e5c95efa3bbe446264d9c36ff5 (patch)
tree2605351e0d3483a99d621c701c58b7949907e5f6 /activesupport/test
parentb8120ab14d695d5ae7392193a6135b5e7cef9c80 (diff)
parentbf7fbe64f70aa15de00dce30ed90f3669540bab7 (diff)
downloadrails-540bc3d9b16d33e5c95efa3bbe446264d9c36ff5.tar.gz
rails-540bc3d9b16d33e5c95efa3bbe446264d9c36ff5.tar.bz2
rails-540bc3d9b16d33e5c95efa3bbe446264d9c36ff5.zip
Merge pull request #16148 from rails/fix_json_autoload
Fix json autoload
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/object/json_cherry_pick_test.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/object/json_cherry_pick_test.rb b/activesupport/test/core_ext/object/json_cherry_pick_test.rb
new file mode 100644
index 0000000000..2f7ea3a497
--- /dev/null
+++ b/activesupport/test/core_ext/object/json_cherry_pick_test.rb
@@ -0,0 +1,42 @@
+require 'abstract_unit'
+
+# These test cases were added to test that cherry-picking the json extensions
+# works correctly, primarily for dependencies problems reported in #16131. They
+# need to be executed in isolation to reproduce the scenario correctly, because
+# other test cases might have already loaded additional dependencies.
+
+class JsonCherryPickTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def test_time_as_json
+ require_or_skip 'active_support/core_ext/object/json'
+
+ expected = Time.new(2004, 7, 25)
+ actual = Time.parse(expected.as_json)
+
+ assert_equal expected, actual
+ end
+
+ def test_date_as_json
+ require_or_skip 'active_support/core_ext/object/json'
+
+ expected = Date.new(2004, 7, 25)
+ actual = Date.parse(expected.as_json)
+
+ assert_equal expected, actual
+ end
+
+ def test_datetime_as_json
+ require_or_skip 'active_support/core_ext/object/json'
+
+ expected = DateTime.new(2004, 7, 25)
+ actual = DateTime.parse(expected.as_json)
+
+ assert_equal expected, actual
+ end
+
+ private
+ def require_or_skip(file)
+ require(file) || skip("'#{file}' was already loaded")
+ end
+end