Sha256: 625cf15e93b1eb56891f19a1ea3d1cc1085e7ea4b00e0b14e6cfa69ff40d8dc8

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 test/lib/definition/mappings_test.rb