mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06: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)
|
||||
end
|
||||
|
||||
def test_sets_use_an_array_serializer
|
||||
assert_equal Set.new.active_model_serializer, ActiveModel::ArraySerializer
|
||||
def test_sets_can_be_serialized
|
||||
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
|
||||
|
||||
class CustomBlog < Blog
|
||||
|
||||
Loading…
Reference in New Issue
Block a user