mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Namespace separator setting for json-api and tests (#1874)
Adds jsonapi_namespace_separator configuration Also: * Enable getting type from record class without serializer Needs Followup: - https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607042 - https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607734
This commit is contained in:
committed by
Benjamin Fleischer
parent
9217bc2ec4
commit
6de3f31b6e
@@ -223,6 +223,25 @@ module ActiveModelSerializers
|
||||
assert_equal expected, relationships
|
||||
end
|
||||
|
||||
def test_underscore_model_namespace_with_namespace_separator_for_linked_resource_type
|
||||
spammy_post = Post.new(id: 123)
|
||||
spammy_post.related = [Spam::UnrelatedLink.new(id: 456)]
|
||||
serializer = SpammyPostSerializer.new(spammy_post)
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer)
|
||||
relationships = with_namespace_separator '--' do
|
||||
adapter.serializable_hash[:data][:relationships]
|
||||
end
|
||||
expected = {
|
||||
related: {
|
||||
data: [{
|
||||
type: 'spam--unrelated-links',
|
||||
id: '456'
|
||||
}]
|
||||
}
|
||||
}
|
||||
assert_equal expected, relationships
|
||||
end
|
||||
|
||||
def test_multiple_references_to_same_resource
|
||||
serializer = ActiveModel::Serializer::CollectionSerializer.new([@first_comment, @second_comment])
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(
|
||||
|
||||
Reference in New Issue
Block a user