aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_hash_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-06-26 11:57:43 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-26 12:01:13 +0200
commit7bd85a8fc2d216a5e2b1d0380df572f782a54d1c (patch)
tree0e9a1b63353b01244bce81bb7262bfb87e92b997 /activesupport/test/ordered_hash_test.rb
parentcfaaed3f40e820d2b4d60c2d8bc1f9a005cee086 (diff)
downloadrails-7bd85a8fc2d216a5e2b1d0380df572f782a54d1c.tar.gz
rails-7bd85a8fc2d216a5e2b1d0380df572f782a54d1c.tar.bz2
rails-7bd85a8fc2d216a5e2b1d0380df572f782a54d1c.zip
Work around the fact the JSON gem was overwriting to_json implementation for all Ruby core classes.
This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized. So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
Diffstat (limited to 'activesupport/test/ordered_hash_test.rb')
-rw-r--r--activesupport/test/ordered_hash_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index dca5c5d0c0..f3d2ec0286 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'active_support/json'
class OrderedHashTest < Test::Unit::TestCase
def setup
@@ -185,6 +186,12 @@ class OrderedHashTest < Test::Unit::TestCase
assert @ordered_hash.inspect.include?(@hash.inspect)
end
+ def test_json
+ ordered_hash = ActiveSupport::OrderedHash[:foo, :bar]
+ hash = Hash[:foo, :bar]
+ assert_equal ordered_hash.to_json, hash.to_json
+ end
+
def test_alternate_initialization_with_splat
alternate = ActiveSupport::OrderedHash[1,2,3,4]
assert_kind_of ActiveSupport::OrderedHash, alternate