mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
In some cases, we want to pass arguments from the controller and we want to serializer a resource according to that. This allows serializers to use the `options` method to retrieve whatever was passed in via arguments.
22 lines
580 B
Ruby
22 lines
580 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class OptionsTest < Minitest::Test
|
|
def setup
|
|
@profile = Profile.new(name: 'Name 1', description: 'Description 1')
|
|
end
|
|
|
|
def test_options_are_accessible
|
|
@profile_serializer = ProfileSerializer.new(@profile, my_options: :accessible)
|
|
assert @profile_serializer.arguments_passed_in?
|
|
end
|
|
|
|
def test_no_option_is_passed_in
|
|
@profile_serializer = ProfileSerializer.new(@profile)
|
|
refute @profile_serializer.arguments_passed_in?
|
|
end
|
|
end
|
|
end
|
|
end
|