diff options
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/serializers/json_serialization_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index bb5be8cdeb..fd4d068354 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -155,6 +155,15 @@ class JsonSerializationTest < ActiveModel::TestCase end end + test "as_json should keep the default order in the hash" do + json = @contact.as_json + keys = json.keys + + %w(name age created_at awesome preferences).each_with_index do |field, index| + assert_equal keys.index(field), index + end + end + test "from_json should work without a root (class attribute)" do json = @contact.to_json result = Contact.new.from_json(json) |