From 89103f1e741b78d6bb26e358363eb961a7779044 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Wed, 11 Jan 2012 13:07:43 -0700 Subject: [PATCH] Test that has_one works. --- test/association_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/association_test.rb b/test/association_test.rb index d7c89640..2f33ae96 100644 --- a/test/association_test.rb +++ b/test/association_test.rb @@ -105,5 +105,23 @@ class AssociationTest < ActiveModel::TestCase ] }, @root_hash) end + + def test_with_default_has_one + @post_serializer_class.class_eval do + has_one :comment + end + + include! :comment + + assert_equal({ + :comment => 1 + }, @hash) + + assert_equal({ + :comments => [ + { :body => "ZOMG A COMMENT" } + ] + }, @root_hash) + end end end