require 'helper' class AxleAttributes::Definition::MappingsTest < ActiveSupport::TestCase test 'to_options' do definition = AxleAttributes::Definition.new Business, :repair_services definition.mappings = {'bar' => 'Foo'} assert_equal([['Foo', 'bar']], definition.to_options) end test 'attribute_mapping' do attribute_mapping = create :attribute_mapping, namespace: 'Business', attribute_name: 'repair_services', label: 'Foo', value: 'bar' definition = AxleAttributes::Definition.new Business, :repair_services assert_equal({'bar' => 'Foo'}, definition.mappings) assert_equal([attribute_mapping], definition.mapping_records) end test 'mapping_model' do foo = AxleAttributes::Definition.new Business, :foo, mapping_model: 'Vegetable' assert_equal Vegetable, foo.mapping_model assert_equal(Vegetable.cached_mapping, foo.mappings) end end