diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-07-12 02:58:43 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-07-29 00:04:36 -0700 |
commit | 5de072c73082d901cc319a810fe6159065c26257 (patch) | |
tree | 1520d48092afbfb73539451bfa991ab837806240 /activesupport | |
parent | 6924f848c45897004ba9cc4f96c032286dcce346 (diff) | |
download | rails-5de072c73082d901cc319a810fe6159065c26257.tar.gz rails-5de072c73082d901cc319a810fe6159065c26257.tar.bz2 rails-5de072c73082d901cc319a810fe6159065c26257.zip |
Added failing test case for #16131
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/core_ext/object/json_cherry_pick_test.rb | 42 |
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 |