mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Add :only/:except options
This commit is contained in:
committed by
Adrian Mugnolo
parent
3201c63162
commit
2e31a14125
@@ -2,6 +2,26 @@ require 'test_helper'
|
||||
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class FilterOptionsTest < Minitest::Test
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
end
|
||||
|
||||
def test_only_option
|
||||
@profile_serializer = ProfileSerializer.new(@profile, only: :name)
|
||||
assert_equal({
|
||||
'profile' => { name: 'Name 1' }
|
||||
}, @profile_serializer.as_json)
|
||||
end
|
||||
|
||||
def test_except_option
|
||||
@profile_serializer = ProfileSerializer.new(@profile, except: :comments)
|
||||
assert_equal({
|
||||
'profile' => { name: 'Name 1', description: 'Description 1' }
|
||||
}, @profile_serializer.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
class FilterAttributesTest < Minitest::Test
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
|
||||
Reference in New Issue
Block a user