diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-21 23:41:07 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-21 23:41:07 +0000 |
commit | 58f2bd0cfc1713ee3ed519d6b75bbfa386c131c3 (patch) | |
tree | b05a3e6dd23bc1eb3f10a596df149aa1409a6b50 /activerecord/test | |
parent | 913f229e21263e5aef541af5918e23cb0675b7ce (diff) | |
download | rails-58f2bd0cfc1713ee3ed519d6b75bbfa386c131c3.tar.gz rails-58f2bd0cfc1713ee3ed519d6b75bbfa386c131c3.tar.bz2 rails-58f2bd0cfc1713ee3ed519d6b75bbfa386c131c3.zip |
Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@241 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/validations_test.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index edd5356e23..867be0376d 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -125,20 +125,34 @@ class ValidationsTest < Test::Unit::TestCase assert developer.save end + def test_title_confirmation_no_confirm + Topic.validates_confirmation_of(:title) + + t = Topic.create("title" => "We should not be confirmed") + assert t.save + end + def test_title_confirmation Topic.validates_confirmation_of(:title) - t = Topic.create("title" => "We should be confirmed") + t = Topic.create("title" => "We should be confirmed","title_confirmation" => "") assert !t.save t.title_confirmation = "We should be confirmed" assert t.save end + def test_terms_of_service_agreement_no_acceptance + Topic.validates_acceptance_of(:terms_of_service, :on => :create) + + t = Topic.create("title" => "We should not be confirmed") + assert t.save + end + def test_terms_of_service_agreement Topic.validates_acceptance_of(:terms_of_service, :on => :create) - t = Topic.create("title" => "We should be confirmed") + t = Topic.create("title" => "We should be confirmed","terms_of_service" => "") assert !t.save assert_equal "must be accepted", t.errors.on(:terms_of_service) @@ -150,7 +164,7 @@ class ValidationsTest < Test::Unit::TestCase def test_eula Topic.validates_acceptance_of(:eula, :message => "must be abided", :on => :create) - t = Topic.create("title" => "We should be confirmed") + t = Topic.create("title" => "We should be confirmed","eula" => "") assert !t.save assert_equal "must be abided", t.errors.on(:eula) @@ -354,4 +368,4 @@ class ValidationsTest < Test::Unit::TestCase assert_equal 100, d.salary assert_equal "100,000", d.salary_before_type_cast end -end
\ No newline at end of file +end |