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