mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Add tests for has_many polymorphic
This commit is contained in:
27
test/fixtures/poro.rb
vendored
27
test/fixtures/poro.rb
vendored
@@ -38,6 +38,19 @@ end
|
||||
class WebLog < Model
|
||||
end
|
||||
|
||||
class Mail < Model
|
||||
def attachments
|
||||
@attachments ||= [Image.new(url: 'U1'),
|
||||
Video.new(html: 'H1')]
|
||||
end
|
||||
end
|
||||
|
||||
class Image < Model
|
||||
end
|
||||
|
||||
class Video < Model
|
||||
end
|
||||
|
||||
###
|
||||
## Serializers
|
||||
###
|
||||
@@ -73,3 +86,17 @@ end
|
||||
class WebLogLowerCamelSerializer < WebLogSerializer
|
||||
format_keys :lower_camel
|
||||
end
|
||||
|
||||
class MailSerializer < ActiveModel::Serializer
|
||||
attributes :body
|
||||
|
||||
has_many :attachments, polymorphic: true
|
||||
end
|
||||
|
||||
class ImageSerializer < ActiveModel::Serializer
|
||||
attributes :url
|
||||
end
|
||||
|
||||
class VideoSerializer < ActiveModel::Serializer
|
||||
attributes :html
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user