Sha256: 7ace1be14d66e16a1d0cbd7182141a4bff6da9277e7dfa1d3f6043a45b57ca72
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
require 'helper' class AxleAttributes::ChildDefinitionTest < ActiveSupport::TestCase class TestModel < Superstore::Base include AxleAttributes::SerializedChild end test 'display_name' do assert_equal 'Test model: Foo', AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :integer).display_name assert_equal 'Test model: Foo', AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :integer).display_name end test 'canonical_name' do assert_equal 'axle_attributes_child_definition_test_test_model.foo', AxleAttributes::ChildDefinition.new(TestModel, :foo).canonical_name end test 'setup types' do AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :integer).setup! assert_kind_of Superstore::Types::IntegerType, TestModel.attribute_definitions['foo'].type AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :boolean).setup! assert_kind_of Superstore::Types::BooleanType, TestModel.attribute_definitions['foo'].type AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :string).setup! assert_kind_of Superstore::Types::StringType, TestModel.attribute_definitions['foo'].type AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :text).setup! assert_kind_of Superstore::Types::StringType, TestModel.attribute_definitions['foo'].type AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :json).setup! assert_kind_of Superstore::Types::JsonType, TestModel.attribute_definitions['foo'].type end test 'setup versioned' do TestModel.versioned_attributes.clear AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :boolean, version: true).setup! assert_equal ['foo'].to_set, TestModel.versioned_attributes TestModel.versioned_attributes.clear AxleAttributes::ChildDefinition.new(TestModel, :foo, type: :boolean).setup! assert_equal [].to_set, TestModel.versioned_attributes end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axle_attributes-1.13.2 | test/lib/child_definition_test.rb |