From c4e6cd48b6324ca6a512a5f9c173ee8609732ede Mon Sep 17 00:00:00 2001 From: Vladimir Lyzo Date: Wed, 13 Aug 2014 11:19:42 +0400 Subject: [PATCH] Add failing test: serialize array with format_keys w/o root --- .../action_controller/serialization_test.rb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/integration/action_controller/serialization_test.rb b/test/integration/action_controller/serialization_test.rb index 9065e211..5d173606 100644 --- a/test/integration/action_controller/serialization_test.rb +++ b/test/integration/action_controller/serialization_test.rb @@ -210,6 +210,43 @@ module ActionController end end + class LowerCamelWoRootSerializerTest < ActionController::TestCase + class WebLogController < ActionController::Base + def render_without_root + render json: WebLog.new({name: 'Name 1', display_name: 'Display Name 1'}), + root: false, + serializer: WebLogLowerCamelSerializer + end + end + + tests WebLogController + + def test_render_without_root + get :render_without_root + assert_equal 'application/json', @response.content_type + assert_equal '{"name":"Name 1","displayName":"Display Name 1"}', @response.body + end + end + + class LowerCamelArrayWoRootSerializerTest < ActionController::TestCase + class WebLogController < ActionController::Base + def render_array_without_root + render json: [WebLog.new({name: 'Name 1', display_name: 'Display Name 1'}), + WebLog.new({name: 'Name 2', display_name: 'Display Name 2'})], + root: false, + each_serializer: WebLogLowerCamelSerializer + end + end + + tests WebLogController + + def test_render_array_without_root + get :render_array_without_root + assert_equal 'application/json', @response.content_type + assert_equal '[{"name":"Name 1","displayName":"Display Name 1"},{"name":"Name 2","displayName":"Display Name 2"}]', @response.body + end + end + class ArrayEmbedingSerializerTest < ActionController::TestCase def setup super