mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Actually test set serialization
This commit is contained in:
parent
7072e79787
commit
5111615ac1
@ -434,8 +434,20 @@ class SerializerTest < ActiveModel::TestCase
|
|||||||
], serializer.as_json)
|
], serializer.as_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sets_use_an_array_serializer
|
def test_sets_can_be_serialized
|
||||||
assert_equal Set.new.active_model_serializer, ActiveModel::ArraySerializer
|
post1 = Post.new(:title => "Post1", :author => "Author1", :id => 1)
|
||||||
|
post2 = Post.new(:title => "Post2", :author => "Author2", :id => 2)
|
||||||
|
|
||||||
|
set = Set.new
|
||||||
|
set << post1
|
||||||
|
set << post2
|
||||||
|
|
||||||
|
serializer = set.active_model_serializer.new set, :each_serializer => CustomPostSerializer
|
||||||
|
|
||||||
|
assert_equal([
|
||||||
|
{ :title => "Post1" },
|
||||||
|
{ :title => "Post2" }
|
||||||
|
], serializer.as_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
class CustomBlog < Blog
|
class CustomBlog < Blog
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user