test/abstract.rb in dm-is-reflective-1.0.0 vs test/abstract.rb in dm-is-reflective-1.0.1.rc
- old
+ new
@@ -6,12 +6,12 @@
module Abstract
def setup_data_mapper
raise 'please provide a clean database because it is a destructive test!!'
end
- AttrCommon = {:required => false}
- AttrCommonPK = {:serial => true, :key => true, :required => true}
+ AttrCommon = {:allow_nil => true}
+ AttrCommonPK = {:serial => true, :key => true, :allow_nil => false}
AttrText = {:length => 65535}.merge(AttrCommon)
def user_fields
[[:created_at, DateTime, AttrCommon],
[:id, DataMapper::Property::Serial, AttrCommonPK],
@@ -20,12 +20,12 @@
end
def comment_fields
[[:body, DataMapper::Property::Text, AttrText],
[:id, DataMapper::Property::Serial, AttrCommonPK],
- [:title, String, {:length => 50, :default => 'default title'}.
- merge(AttrCommon)],
+ [:title, String, {:length => 50, :default => 'default title',
+ :allow_nil => false}],
[:user_id, Integer, AttrCommon]]
end
# there's differences between adapters
def super_user_fields
@@ -65,11 +65,12 @@
class Comment
include DataMapper::Resource
belongs_to :user, :required => false
property :id, Serial
- property :title, String, :length => 50, :default => 'default title'
+ property :title, String, :length => 50, :default => 'default title',
+ :allow_nil => false
property :body, Text
is :reflective
end
@@ -192,9 +193,13 @@
def test_invalid_argument
assert_raises(ArgumentError){
User.send :reflect, 29
}
+ end
+
+ def test_allow_empty_string
+ assert Comment.new(:title => '').save
end
def test_auto_genclasses
scope = new_scope
assert_equal ["#{scope == Object ? '' : "#{scope}::"}AbstractComment",