test/unit/test_validations.rb in mongo_mapper-0.8.3 vs test/unit/test_validations.rb in mongo_mapper-0.8.4
- old
+ new
@@ -5,9 +5,29 @@
context "on a Document" do
setup do
@document = Doc()
end
+ context "Validating uniquness of" do
+ should "not validate nil when allow_nil false" do
+ @document.key :name, String
+ @document.validates_uniqueness_of :name, :allow_nil => false
+ doc = @document.new(:name => nil)
+ doc.should have_error_on(:name)
+ doc.name = "Ryan"
+ doc.should_not have_error_on(:name)
+ end
+
+ should "not validate blank when allow_blank false" do
+ @document.key :name, String
+ @document.validates_uniqueness_of :name, :allow_blank => false
+ doc = @document.new(:name => "")
+ doc.should have_error_on(:name)
+ doc.name = "Ryan"
+ doc.should_not have_error_on(:name)
+ end
+ end
+
context "Validating acceptance of" do
should "work with validates_acceptance_of macro" do
@document.key :terms, String
@document.validates_acceptance_of :terms
doc = @document.new(:terms => '')