Skip to content

Commit 3296912

Browse files
committed
disabling custom root option
1 parent d061b2e commit 3296912

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

lib/active_model/serializer.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,7 @@ def initialize(object, options = {})
168168
end
169169

170170
def json_key
171-
if root.nil?
172-
self.class.root_name
173-
else
174-
root
175-
end
171+
self.class.root_name
176172
end
177173

178174
def id

test/action_controller/serialization_test.rb

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,6 @@ def test_render_using_implicit_serializer
173173
assert_equal expected.to_json, @response.body
174174
end
175175

176-
def test_render_using_custom_root
177-
get :render_using_custom_root
178-
179-
assert_equal 'application/json', @response.content_type
180-
assert_equal '{"custom_root":{"name":"Name 1","description":"Description 1"}}', @response.body
181-
end
182-
183-
def test_render_using_custom_root_and_meta
184-
get :render_using_custom_root_and_meta
185-
186-
assert_equal 'application/json', @response.content_type
187-
assert_equal '{"custom_root":{"name":"Name 1","description":"Description 1"},"meta":{"total":10}}', @response.body
188-
end
189-
190176
def test_render_using_default_root
191177
get :render_using_default_adapter_root
192178

@@ -223,26 +209,6 @@ def test_render_using_custom_root_in_adapter_with_a_default
223209
assert_equal expected.to_json, @response.body
224210
end
225211

226-
def test_render_array_using_custom_root_and_meta
227-
get :render_array_using_custom_root_and_meta
228-
229-
assert_equal 'application/json', @response.content_type
230-
231-
expected = { custom_root: [
232-
{
233-
name: 'Name 1',
234-
description: 'Description 1',
235-
},
236-
{
237-
name: 'Name 2',
238-
description: 'Description 2',
239-
}],
240-
meta: { total: 10 }
241-
}
242-
243-
assert_equal expected.to_json, @response.body
244-
end
245-
246212
def test_render_array_using_implicit_serializer
247213
get :render_array_using_implicit_serializer
248214
assert_equal 'application/json', @response.content_type

0 commit comments

Comments
 (0)