mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge branch 'master' into domitian-move-namespace-of-adapter-to-active-model-serializers
Conflicts: CHANGELOG.md lib/active_model/serializer/adapter/attributes.rb lib/active_model/serializer/adapter/cached_serializer.rb lib/active_model/serializer/adapter/fragment_cache.rb lib/active_model/serializer/adapter/json_api.rb lib/active_model/serializer/adapter/json_api/link.rb test/adapter/fragment_cache_test.rb test/adapter/json_api/links_test.rb test/adapter/json_api/resource_type_config_test.rb
This commit is contained in:
@@ -45,6 +45,16 @@ module ActionController
|
||||
render json: @profiles, meta: { total: 10 }
|
||||
end
|
||||
|
||||
def render_array_using_implicit_serializer_and_links
|
||||
with_adapter ActiveModelSerializers::Adapter::JsonApi do
|
||||
@profiles = [
|
||||
Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
||||
]
|
||||
|
||||
render json: @profiles, links: { self: 'http://example.com/api/profiles/1' }
|
||||
end
|
||||
end
|
||||
|
||||
def render_object_with_cache_enabled
|
||||
@comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
|
||||
@author = Author.new(id: 1, name: 'Joao Moura.')
|
||||
@@ -254,6 +264,29 @@ module ActionController
|
||||
assert_equal expected.to_json, @response.body
|
||||
end
|
||||
|
||||
def test_render_array_using_implicit_serializer_and_links
|
||||
get :render_array_using_implicit_serializer_and_links
|
||||
|
||||
expected = {
|
||||
data: [
|
||||
{
|
||||
id: assigns(:profiles).first.id.to_s,
|
||||
type: 'profiles',
|
||||
attributes: {
|
||||
name: 'Name 1',
|
||||
description: 'Description 1'
|
||||
}
|
||||
}
|
||||
],
|
||||
links: {
|
||||
self: 'http://example.com/api/profiles/1'
|
||||
}
|
||||
}
|
||||
|
||||
assert_equal 'application/json', @response.content_type
|
||||
assert_equal expected.to_json, @response.body
|
||||
end
|
||||
|
||||
def test_render_with_cache_enable
|
||||
expected = {
|
||||
id: 1,
|
||||
|
||||
Reference in New Issue
Block a user