Sha256: 333bf24136adc7e3ec59e1519ff1f73f647750804bb77998a7d7bbec8f9d573a

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'helper'

class AxleAttributes::ModelTest < ActiveSupport::TestCase
  class Person < Superstore::Base
    include AxleAttributes::Model
  end

  test 'definition_class' do
    assert_equal '::AxleAttributes::ParentDefinition', Person.has_attribute_definition_class
  end

  test 'core attributes' do
    refute_nil Person.attributes['created_at']
    refute_nil Person.attributes['updated_at']
    refute_nil Person.attributes['segment_id']

    assert Person.attributes['created_at'].readonly?
    assert Person.attributes['updated_at'].readonly?
    assert Person.attributes['segment_id'].readonly?

    assert_equal({type: "date", format: "dateOptionalTime", doc_values: true}, Person.elastic_index.mapping[:properties]['created_at'])
    assert_equal({type: "date", format: "dateOptionalTime", doc_values: true}, Person.elastic_index.mapping[:properties]['updated_at'])
    assert_equal({type: "long", doc_values: true}, Person.elastic_index.mapping[:properties]['segment_id'])
  end

  module Framework
    class Base < Superstore::Base
      include AxleAttributes::Model
    end
  end

  class InheritedModel < Framework::Base
  end

  test 'core attribute inheritence' do
    assert_nil Framework::Base.attributes['created_at']
    assert_nil Framework::Base.attributes['updated_at']
    assert_nil Framework::Base.attributes['segment_id']

    refute_nil Person.attributes['created_at']
    refute_nil Person.attributes['updated_at']
    refute_nil Person.attributes['segment_id']
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 test/lib/model_test.rb