@@ -10,13 +10,17 @@ def render_using_implicit_serializer
10
10
end
11
11
12
12
def render_using_custom_root
13
- @profile = Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } )
14
- render json : @profile , root : "custom_root"
13
+ with_adapter ActiveModel ::Serializer ::Adapter ::Json do
14
+ @profile = Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } )
15
+ render json : @profile , root : "custom_root"
16
+ end
15
17
end
16
18
17
19
def render_using_custom_root_and_meta
18
- @profile = Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } )
19
- render json : @profile , root : "custom_root" , meta : { total : 10 }
20
+ with_adapter ActiveModel ::Serializer ::Adapter ::Json do
21
+ @profile = Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } )
22
+ render json : @profile , root : "custom_root" , meta : { total : 10 }
23
+ end
20
24
end
21
25
22
26
def render_using_default_adapter_root
@@ -34,11 +38,13 @@ def render_using_custom_root_in_adapter_with_a_default
34
38
end
35
39
36
40
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 }
41
+ with_adapter ActiveModel ::Serializer ::Adapter ::Json do
42
+ array = [
43
+ Profile . new ( { name : 'Name 1' , description : 'Description 1' , comments : 'Comments 1' } ) ,
44
+ Profile . new ( { name : 'Name 2' , description : 'Description 2' , comments : 'Comments 2' } )
45
+ ]
46
+ render json : array , root : "custom_root" , meta : { total : 10 }
47
+ end
42
48
end
43
49
44
50
def render_array_using_implicit_serializer
@@ -219,6 +225,7 @@ def test_render_using_custom_root_in_adapter_with_a_default
219
225
220
226
def test_render_array_using_custom_root_and_meta
221
227
get :render_array_using_custom_root_and_meta
228
+
222
229
assert_equal 'application/json' , @response . content_type
223
230
224
231
expected = { custom_root : [
0 commit comments