aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/validations_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-09 14:37:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-09 14:37:37 +0000
commit27ea0b527e172bbc8f8b68c39c8359ee0c77e435 (patch)
tree00f76609affbfd723213e2298158410526614fe0 /activerecord/test/validations_test.rb
parentd33f814db500538cee14b3db83afaef5f671a692 (diff)
downloadrails-27ea0b527e172bbc8f8b68c39c8359ee0c77e435.tar.gz
rails-27ea0b527e172bbc8f8b68c39c8359ee0c77e435.tar.bz2
rails-27ea0b527e172bbc8f8b68c39c8359ee0c77e435.zip
Added Base.validate_confirmation that encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@97 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/validations_test.rb')
-rwxr-xr-xactiverecord/test/validations_test.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index a6cdc0a706..c396d30630 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -120,25 +120,28 @@ class ValidationsTest < Test::Unit::TestCase
developer.name = "Just right"
assert developer.save
end
-end
+ def test_title_confirmation
+ Topic.validate_confirmation(:title)
-class MacroValidationsTest < Test::Unit::TestCase
- fixtures :topics, :developers
+ t = Topic.create("title" => "We should be confirmed")
+ assert !t.save
- def setup
- Topic.validate_confirmation(:title)
- end
+ t.title_confirmation = "We should be confirmed"
+ assert t.save
- def teardown
Topic.write_inheritable_attribute("validate_on_create", [])
end
- def test_title_confirmation
+ def test_terms_of_service_agreement
+ Topic.validate_acceptance(:terms_of_service)
+
t = Topic.create("title" => "We should be confirmed")
assert !t.save
- t.title_confirmation = "We should be confirmed"
+ t.terms_of_service = "1"
assert t.save
+
+ Topic.write_inheritable_attribute("validate_on_create", [])
end
end \ No newline at end of file