mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
updating tests to match new adapters structure
This commit is contained in:
@@ -77,12 +77,10 @@ module ActionController
|
||||
get :render_array_using_explicit_serializer
|
||||
assert_equal 'application/json', @response.content_type
|
||||
|
||||
expected = {
|
||||
'paginated' => [
|
||||
{ 'name' => 'Name 1' },
|
||||
{ 'name' => 'Name 2' }
|
||||
]
|
||||
}
|
||||
expected = [
|
||||
{ 'name' => 'Name 1' },
|
||||
{ 'name' => 'Name 2' }
|
||||
]
|
||||
|
||||
assert_equal expected.to_json, @response.body
|
||||
end
|
||||
|
||||
@@ -10,13 +10,17 @@ module ActionController
|
||||
end
|
||||
|
||||
def render_using_custom_root
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "custom_root"
|
||||
with_adapter ActiveModel::Serializer::Adapter::Json do
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "custom_root"
|
||||
end
|
||||
end
|
||||
|
||||
def render_using_custom_root_and_meta
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "custom_root", meta: { total: 10 }
|
||||
with_adapter ActiveModel::Serializer::Adapter::Json do
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "custom_root", meta: { total: 10 }
|
||||
end
|
||||
end
|
||||
|
||||
def render_using_default_adapter_root
|
||||
@@ -34,11 +38,13 @@ module ActionController
|
||||
end
|
||||
|
||||
def render_array_using_custom_root_and_meta
|
||||
array = [
|
||||
Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
|
||||
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })
|
||||
]
|
||||
render json: array, root: "custom_root", meta: { total: 10 }
|
||||
with_adapter ActiveModel::Serializer::Adapter::Json do
|
||||
array = [
|
||||
Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
|
||||
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })
|
||||
]
|
||||
render json: array, root: "custom_root", meta: { total: 10 }
|
||||
end
|
||||
end
|
||||
|
||||
def render_array_using_implicit_serializer
|
||||
@@ -219,6 +225,7 @@ module ActionController
|
||||
|
||||
def test_render_array_using_custom_root_and_meta
|
||||
get :render_array_using_custom_root_and_meta
|
||||
|
||||
assert_equal 'application/json', @response.content_type
|
||||
|
||||
expected = { custom_root: [
|
||||
|
||||
Reference in New Issue
Block a user