diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
commit | b04230e3bbf912d60601e9e7b797c4cd43581d51 (patch) | |
tree | 97a2f784a2ec2bfae4f960af56a9280dad6f7774 /activemodel/test/cases/validations/with_validation_test.rb | |
parent | 867829b187969607aa12f2b0457f25da9c204db0 (diff) | |
parent | 6e3bee6cf1f0d2684152292db0a8b757249824fd (diff) | |
download | rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.gz rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.bz2 rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.zip |
Merge remote branch 'mainstream/master'
Conflicts:
actionpack/lib/action_controller/metal/flash.rb
Diffstat (limited to 'activemodel/test/cases/validations/with_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/with_validation_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/with_validation_test.rb b/activemodel/test/cases/validations/with_validation_test.rb index 7540ccb580..66b072ea38 100644 --- a/activemodel/test/cases/validations/with_validation_test.rb +++ b/activemodel/test/cases/validations/with_validation_test.rb @@ -120,6 +120,28 @@ class ValidatesWithTest < ActiveRecord::TestCase Topic.validates_with(validator, :if => "1 == 1", :foo => :bar) assert topic.valid? end + + test "calls setup method of validator passing in self when validator has setup method" do + topic = Topic.new + validator = stub_everything + validator.stubs(:new).returns(validator) + validator.stubs(:validate) + validator.stubs(:respond_to?).with(:setup).returns(true) + validator.expects(:setup).with(Topic).once + Topic.validates_with(validator) + assert topic.valid? + end + + test "doesn't call setup method of validator when validator has no setup method" do + topic = Topic.new + validator = stub_everything + validator.stubs(:new).returns(validator) + validator.stubs(:validate) + validator.stubs(:respond_to?).with(:setup).returns(false) + validator.expects(:setup).with(Topic).never + Topic.validates_with(validator) + assert topic.valid? + end test "validates_with with options" do Topic.validates_with(ValidatorThatValidatesOptions, :field => :first_name) |