From 9f8116fb778ab4b90592d0a9ab88316132f00a78 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Fri, 9 Aug 2013 04:32:00 +0530 Subject: Add tests for ActiveModel::Serializers::JSON#as_json ordering --- activemodel/test/cases/serializers/json_serialization_test.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activemodel/test') diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index f0347081ee..476ba3d8c5 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -155,12 +155,21 @@ class JsonSerializationTest < ActiveModel::TestCase end end - test "as_json should keep the default order in the hash" do + test "as_json should keep the MRI default order in the hash" do + skip "on JRuby as order is different" if defined? JRUBY_VERSION json = @contact.as_json assert_equal %w(name age created_at awesome preferences), json.keys end + test "as_json should keep the JRuby default order in the hash" do + skip "on MRI as order is different" unless defined? JRUBY_VERSION + json = @contact.as_json + + assert_equal %w(age name created_at awesome preferences), json.keys + end + + test "from_json should work without a root (class attribute)" do json = @contact.to_json result = Contact.new.from_json(json) -- cgit v1.2.3