mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Cleaner unsuffixed association keys tests
This commit is contained in:
parent
226cbc4160
commit
a39d08d2ad
22
test/fixtures/poro.rb
vendored
22
test/fixtures/poro.rb
vendored
@ -142,3 +142,25 @@ module TestNamespace
|
|||||||
class ProfileSerializer < ::ProfileSerializer; end
|
class ProfileSerializer < ::ProfileSerializer; end
|
||||||
class UserSerializer < ::UserSerializer; end
|
class UserSerializer < ::UserSerializer; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ActiveModel::Serializer.setup do |config|
|
||||||
|
config.default_key_type = :name
|
||||||
|
end
|
||||||
|
|
||||||
|
class NameKeyUserSerializer < ActiveModel::Serializer
|
||||||
|
attributes :name, :email
|
||||||
|
|
||||||
|
has_one :profile
|
||||||
|
end
|
||||||
|
|
||||||
|
class NameKeyPostSerializer < ActiveModel::Serializer
|
||||||
|
attributes :title, :body
|
||||||
|
|
||||||
|
has_many :comments
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveModel::Serializer.setup do |config|
|
||||||
|
config.default_key_type = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -243,14 +243,6 @@ module ActiveModel
|
|||||||
}, @post_serializer.as_json)
|
}, @post_serializer.as_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
CONFIG.default_key_type = :name
|
|
||||||
class NameKeyPostSerializer < ActiveModel::Serializer
|
|
||||||
attributes :title, :body
|
|
||||||
|
|
||||||
has_many :comments
|
|
||||||
end
|
|
||||||
CONFIG.default_key_type = nil
|
|
||||||
|
|
||||||
def test_associations_name_key_embedding_ids_serialization_using_serializable_hash
|
def test_associations_name_key_embedding_ids_serialization_using_serializable_hash
|
||||||
@association = NameKeyPostSerializer._associations[:comments]
|
@association = NameKeyPostSerializer._associations[:comments]
|
||||||
@association.embed = :ids
|
@association.embed = :ids
|
||||||
|
|||||||
@ -217,14 +217,6 @@ module ActiveModel
|
|||||||
}, @user_serializer.as_json)
|
}, @user_serializer.as_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
CONFIG.default_key_type = :name
|
|
||||||
class NameKeyUserSerializer < ActiveModel::Serializer
|
|
||||||
attributes :name, :email
|
|
||||||
|
|
||||||
has_one :profile
|
|
||||||
end
|
|
||||||
CONFIG.default_key_type = nil
|
|
||||||
|
|
||||||
def test_associations_name_key_embedding_ids_serialization_using_serializable_hash
|
def test_associations_name_key_embedding_ids_serialization_using_serializable_hash
|
||||||
@association = NameKeyUserSerializer._associations[:profile]
|
@association = NameKeyUserSerializer._associations[:profile]
|
||||||
@association.embed = :ids
|
@association.embed = :ids
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user