mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22: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 UserSerializer < ::UserSerializer; 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)
|
||||
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
|
||||
@association = NameKeyPostSerializer._associations[:comments]
|
||||
@association.embed = :ids
|
||||
|
||||
@ -217,14 +217,6 @@ module ActiveModel
|
||||
}, @user_serializer.as_json)
|
||||
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
|
||||
@association = NameKeyUserSerializer._associations[:profile]
|
||||
@association.embed = :ids
|
||||
|
||||
Loading…
Reference in New Issue
Block a user