mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
This functionality used to exist in v0.8.1. This adds the ability to pass other options that will be usable in the serializer via the options accessor. This works by adding an attr_accessor for options so it is available and is set by the remaining options in the provided options hash during initialization.
18 lines
488 B
Ruby
18 lines
488 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class OptionsTest < ActiveModel::TestCase
|
|
def setup
|
|
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
|
end
|
|
|
|
def test_meta
|
|
profile_serializer = ProfileSerializer.new(@profile, root: 'profile', random_option: "This is an option")
|
|
|
|
assert_equal("This is an option", profile_serializer.options[:random_option])
|
|
end
|
|
end
|
|
end
|
|
end
|