Skip to content

Commit

Permalink
Merge pull request rails#8066 from cfabianski/AddTestForSerialization…
Browse files Browse the repository at this point in the history
…Method

Add test for code change introduced in this commit f20032f
  • Loading branch information
carlosantoniodasilva committed Oct 29, 2012
2 parents 008154e + 3152ee8 commit a4ac2b4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions activemodel/test/cases/serializers/json_serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ def @contact.favorite_quote; "Constraints are liberating"; end
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)
Expand Down

0 comments on commit a4ac2b4

Please sign in to comment.