active_model_serializers/test/serializers/options_test.rb
Alexandre de Oliveira 48650ecf7e Makes passed in options accessible inside serializers
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.
2015-03-11 14:53:57 -03:00

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