test/unit/user_test.rb in quo_vadis-1.0.7 vs test/unit/user_test.rb in quo_vadis-1.1.0
- old
+ new
@@ -26,6 +26,23 @@
User.create :username => 'bob', :password => 'secret'
user = User.last
assert user.has_matching_password?('secret')
end
+ test 'conditional validation' do
+ user = User.new
+ user.class_eval <<-END
+ def should_authenticate?
+ username == 'bob'
+ end
+ END
+ user.username = 'bob'
+ assert !user.valid?
+
+ user.username = 'robert'
+ assert user.valid?
+
+ user.username = nil
+ assert user.valid?
+ end
+
end