aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorCédric FABIANSKI <cfabianski@leadformance.com>2012-10-29 21:55:09 +0100
committerCédric FABIANSKI <cfabianski@leadformance.com>2012-10-29 21:55:09 +0100
commit3152ee878a38b25f2128bd670f8d843f9871d47d (patch)
treece2a7ea00dea322380d952e8591a1aa4ef05d1f2 /activemodel/test
parent008154e23705e732f5fa5292aa60605efb92d163 (diff)
downloadrails-3152ee878a38b25f2128bd670f8d843f9871d47d.tar.gz
rails-3152ee878a38b25f2128bd670f8d843f9871d47d.tar.bz2
rails-3152ee878a38b25f2128bd670f8d843f9871d47d.zip
Add test for code change introduced in this commit f20032f
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/serializers/json_serialization_test.rb9
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)