@@ -33,6 +33,14 @@ def render_using_custom_root_in_adapter_with_a_default
33
33
render json : @profile , root : "profile" , adapter : :json_api
34
34
end
35
35
36
+ def render_array_using_custom_root_and_meta
37
+ array = [
38
+ Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } ) ,
39
+ Profile . new ( { name : 'Name 2' , description : 'Description 2' , comments : 'Comments 2' } )
40
+ ]
41
+ render json : array , root : "custom_root" , meta : { total : 10 }
42
+ end
43
+
36
44
def render_array_using_implicit_serializer
37
45
array = [
38
46
Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } ) ,
@@ -209,6 +217,25 @@ def test_render_using_custom_root_in_adapter_with_a_default
209
217
assert_equal expected . to_json , @response . body
210
218
end
211
219
220
+ def test_render_array_using_custom_root_and_meta
221
+ get :render_array_using_custom_root_and_meta
222
+ assert_equal 'application/json' , @response . content_type
223
+
224
+ expected = { custom_root : [
225
+ {
226
+ name : 'Name 1' ,
227
+ description : 'Description 1' ,
228
+ } ,
229
+ {
230
+ name : 'Name 2' ,
231
+ description : 'Description 2' ,
232
+ } ] ,
233
+ meta : { total : 10 }
234
+ }
235
+
236
+ assert_equal expected . to_json , @response . body
237
+ end
238
+
212
239
def test_render_array_using_implicit_serializer
213
240
get :render_array_using_implicit_serializer
214
241
assert_equal 'application/json' , @response . content_type
0 commit comments