Sha256: b822635e88e3efd19f09ca0ba7706cfcd43887ec6f77697100b5093677e03ed2
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
require 'test_helper' module ActiveModelSerializers module Adapter class AttributesTest < ActiveSupport::TestCase class Person include ActiveModel::Model include ActiveModel::Serialization attr_accessor :first_name, :last_name end class PersonSerializer < ActiveModel::Serializer attributes :first_name, :last_name end def setup ActionController::Base.cache_store.clear end def test_serializable_hash person = Person.new(first_name: 'Arthur', last_name: 'Dent') serializer = PersonSerializer.new(person) adapter = ActiveModelSerializers::Adapter::Attributes.new(serializer) assert_equal({ first_name: 'Arthur', last_name: 'Dent' }, adapter.serializable_hash) end def test_serializable_hash_with_transform_key_casing person = Person.new(first_name: 'Arthur', last_name: 'Dent') serializer = PersonSerializer.new(person) adapter = ActiveModelSerializers::Adapter::Attributes.new( serializer, key_transform: :camel_lower ) assert_equal({ firstName: 'Arthur', lastName: 'Dent' }, adapter.serializable_hash) end end end end
Version data entries
5 entries across 5 versions & 2 rubygems