mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #594 from bolshakov/feature/custom_array_serializer
Support custom array serializer
This commit is contained in:
@@ -9,7 +9,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_serializer_for_array_returns_appropriate_type
|
||||
assert_kind_of ArraySerializer, @serializer
|
||||
assert_kind_of ActiveModel::ArraySerializer, @serializer
|
||||
end
|
||||
|
||||
def test_array_serializer_serializes_simple_objects
|
||||
@@ -18,6 +18,23 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
class CustomArraySerializerSupport < Minitest::Test
|
||||
def setup
|
||||
Object.const_set(:ArraySerializer, Class.new)
|
||||
|
||||
array = [1, 2, 3]
|
||||
@serializer_class = Serializer.serializer_for(array)
|
||||
end
|
||||
|
||||
def teardown
|
||||
Object.send(:remove_const, :ArraySerializer)
|
||||
end
|
||||
|
||||
def test_serializer_for_array_returns_appropriate_type
|
||||
assert_equal ::ArraySerializer, @serializer_class
|
||||
end
|
||||
end
|
||||
|
||||
class ModelSerializationTest < Minitest::Test
|
||||
def test_array_serializer_serializes_models
|
||||
array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
|
||||
|
||||
Reference in New Issue
Block a user