Actually test set serialization

This commit is contained in:
twinturbo 2012-07-15 13:42:29 +02:00
parent 7072e79787
commit 5111615ac1

View File

@ -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