test/abstract.rb in dm-is-reflective-0.8.0 vs test/abstract.rb in dm-is-reflective-0.9.0

- old
+ new

@@ -1,44 +1,44 @@ -require 'rubygems' require 'dm-core' +require 'dm-migrations' require 'dm-is-reflective' module Abstract def setup_data_mapper raise 'please provide a clean database because it is a destructive test!!' end - AttrCommon = {:nullable => true} - AttrCommonPK = {:serial => true, :key => true, :nullable => false} + AttrCommon = {:required => false} + AttrCommonPK = {:serial => true, :key => true, :required => true} AttrText = {:length => 65535}.merge(AttrCommon) def user_fields [[:created_at, DateTime, AttrCommon], - [:id, DataMapper::Types::Serial, AttrCommonPK], + [:id, DataMapper::Property::Serial, AttrCommonPK], [:login, String, {:length => 70}.merge(AttrCommon)], - [:sig, DataMapper::Types::Text, AttrText]] + [:sig, DataMapper::Property::Text, AttrText]] end def comment_fields - [[:body, DataMapper::Types::Text, AttrText], - [:id, DataMapper::Types::Serial, AttrCommonPK], + [[:body, DataMapper::Property::Text, AttrText], + [:id, DataMapper::Property::Serial, AttrCommonPK], [:title, String, {:length => 50, :default => 'default title'}. merge(AttrCommon)], [:user_id, Integer, AttrCommon]] end # there's differences between adapters def super_user_fields case self when MysqlTest # Mysql couldn't tell it's boolean or tinyint [[:bool, Integer, AttrCommon], - [:id, DataMapper::Types::Serial, AttrCommonPK]] + [:id, DataMapper::Property::Serial, AttrCommonPK]] else - [[:bool, DataMapper::Types::Boolean, AttrCommon], - [:id, DataMapper::Types::Serial, AttrCommonPK]] + [[:bool, DataMapper::Property::Boolean, AttrCommon], + [:id, DataMapper::Property::Serial, AttrCommonPK]] end end class User @@ -61,11 +61,11 @@ is :reflective end class Comment include DataMapper::Resource - belongs_to :user, :nullable => true + belongs_to :user, :required => false property :id, Serial property :title, String, :length => 50, :default => 'default title' property :body, Text @@ -164,20 +164,20 @@ def test_reflect_type model, local_dm = create_fake_model model.storage_names[:default] = 'abstract_comments' - model.send :reflect, DataMapper::Types::Serial + model.send :reflect, DataMapper::Property::Serial assert_equal ['id'], model.properties.map(&:name).map(&:to_s).sort model.send :reflect, Integer assert_equal ['id', 'user_id'], model.properties.map(&:name).map(&:to_s).sort end def test_reflect_multiple model, local_dm = create_fake_model model.storage_names[:default] = 'abstract_users' - model.send :reflect, :login, DataMapper::Types::Serial + model.send :reflect, :login, DataMapper::Property::Serial assert_equal ['id', 'login'], model.properties.map(&:name).map(&:to_s).sort end def test_reflect_regexp