mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Test that has_one works.
This commit is contained in:
parent
72b8213bee
commit
89103f1e74
@ -105,5 +105,23 @@ class AssociationTest < ActiveModel::TestCase
|
|||||||
]
|
]
|
||||||
}, @root_hash)
|
}, @root_hash)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user