Adds polymorphic tests and documentation

This commit is contained in:
Marc Garreau
2016-03-15 12:20:00 -06:00
parent 54ddbe2851
commit 045fa9bc07
5 changed files with 114 additions and 0 deletions

18
test/fixtures/poro.rb vendored
View File

@@ -72,6 +72,14 @@ Comment = Class.new(Model) do
end
end
class Employee < ActiveRecord::Base
has_many :pictures, as: :imageable
end
class Picture < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
end
module Spam; end
Spam::UnrelatedLink = Class.new(Model)
@@ -233,6 +241,16 @@ VirtualValueSerializer = Class.new(ActiveModel::Serializer) do
end
end
PolymorphicHasManySerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :name
end
PolymorphicBelongsToSerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :title
has_one :imageable, serializer: PolymorphicHasManySerializer
end
Spam::UnrelatedLinkSerializer = Class.new(ActiveModel::Serializer) do
cache only: [:id]
attributes :id