From 329691276a1bb2827f20bceda5d15fd79a08d3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Mon, 15 Jun 2015 15:58:39 -0300 Subject: [PATCH] disabling custom root option --- lib/active_model/serializer.rb | 6 +--- test/action_controller/serialization_test.rb | 34 -------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 9079b030..1e59cc23 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -168,11 +168,7 @@ module ActiveModel end def json_key - if root.nil? - self.class.root_name - else - root - end + self.class.root_name end def id diff --git a/test/action_controller/serialization_test.rb b/test/action_controller/serialization_test.rb index 5fc4c529..12a75f2d 100644 --- a/test/action_controller/serialization_test.rb +++ b/test/action_controller/serialization_test.rb @@ -173,20 +173,6 @@ module ActionController assert_equal expected.to_json, @response.body end - def test_render_using_custom_root - get :render_using_custom_root - - assert_equal 'application/json', @response.content_type - assert_equal '{"custom_root":{"name":"Name 1","description":"Description 1"}}', @response.body - end - - def test_render_using_custom_root_and_meta - get :render_using_custom_root_and_meta - - assert_equal 'application/json', @response.content_type - assert_equal '{"custom_root":{"name":"Name 1","description":"Description 1"},"meta":{"total":10}}', @response.body - end - def test_render_using_default_root get :render_using_default_adapter_root @@ -223,26 +209,6 @@ module ActionController assert_equal expected.to_json, @response.body end - 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: [ - { - name: 'Name 1', - description: 'Description 1', - }, - { - name: 'Name 2', - description: 'Description 2', - }], - meta: { total: 10 } - } - - assert_equal expected.to_json, @response.body - end - def test_render_array_using_implicit_serializer get :render_array_using_implicit_serializer assert_equal 'application/json', @response.content_type