mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Test to cover serialization_options
This commit is contained in:
parent
341d552ae0
commit
2a1d9346f6
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user