From 2a1d9346f61a18dce64e603b349118029a863eb0 Mon Sep 17 00:00:00 2001 From: Robin Daugherty Date: Sun, 12 Oct 2014 19:25:38 -0400 Subject: [PATCH] Test to cover serialization_options --- .../active_model/serializer/options_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/unit/active_model/serializer/options_test.rb b/test/unit/active_model/serializer/options_test.rb index 986d2071..2e14151f 100644 --- a/test/unit/active_model/serializer/options_test.rb +++ b/test/unit/active_model/serializer/options_test.rb @@ -11,5 +11,24 @@ module ActiveModel assert_equal({foo: :bar}, @serializer.context) end end + + class SerializationOptionsTest < Minitest::Test + def setup + @profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }) + @profile_serializer = ProfileSerializer.new(@profile) + @profile_serializer.instance_eval do + def description + serialization_options[:force_the_description] + end + end + end + + def test_filtered_attributes_serialization + forced_description = "This is a test" + assert_equal({ + 'profile' => { name: 'Name 1', description: forced_description } + }, @profile_serializer.as_json(force_the_description: forced_description)) + end + end end end