aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations/with_validation_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-22 23:12:21 +0100
committerJosé Valim <jose.valim@gmail.com>2009-12-22 23:12:21 +0100
commit2476c5312dcbd29f49672f71617a3d34c6a60cc7 (patch)
tree26394dcc6a26a845269c9a004b3960b01fbe693a /activemodel/test/cases/validations/with_validation_test.rb
parent4b8330d2d50ae4de14dd43ffbea4d91804553140 (diff)
downloadrails-2476c5312dcbd29f49672f71617a3d34c6a60cc7.tar.gz
rails-2476c5312dcbd29f49672f71617a3d34c6a60cc7.tar.bz2
rails-2476c5312dcbd29f49672f71617a3d34c6a60cc7.zip
Validator is simply sent to validate method. However, the API needs to change, so validate accepts a record.
Diffstat (limited to 'activemodel/test/cases/validations/with_validation_test.rb')
-rw-r--r--activemodel/test/cases/validations/with_validation_test.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activemodel/test/cases/validations/with_validation_test.rb b/activemodel/test/cases/validations/with_validation_test.rb
index fae87a6188..4350ad69ec 100644
--- a/activemodel/test/cases/validations/with_validation_test.rb
+++ b/activemodel/test/cases/validations/with_validation_test.rb
@@ -14,24 +14,24 @@ class ValidatesWithTest < ActiveRecord::TestCase
OTHER_ERROR_MESSAGE = "Validation error from other validator"
class ValidatorThatAddsErrors < ActiveModel::Validator
- def validate()
+ def validate(record)
record.errors[:base] << ERROR_MESSAGE
end
end
class OtherValidatorThatAddsErrors < ActiveModel::Validator
- def validate()
+ def validate(record)
record.errors[:base] << OTHER_ERROR_MESSAGE
end
end
class ValidatorThatDoesNotAddErrors < ActiveModel::Validator
- def validate()
+ def validate(record)
end
end
class ValidatorThatValidatesOptions < ActiveModel::Validator
- def validate()
+ def validate(record)
if options[:field] == :first_name
record.errors[:base] << ERROR_MESSAGE
end
@@ -101,8 +101,8 @@ class ValidatesWithTest < ActiveRecord::TestCase
test "passes all non-standard configuration options to the validator class" do
topic = Topic.new
validator = mock()
- validator.expects(:new).with(topic, {:foo => :bar}).returns(validator)
- validator.expects(:validate)
+ validator.expects(:new).with({:foo => :bar}).returns(validator)
+ validator.expects(:validate).with(topic)
Topic.validates_with(validator, :if => "1 == 1", :foo => :bar)
assert topic.valid?