diff options
author | Dan Pickett <dpickett@enlightsolutions.com> | 2012-01-06 18:59:36 -0500 |
---|---|---|
committer | Dan Pickett <dpickett@enlightsolutions.com> | 2012-01-06 18:59:36 -0500 |
commit | 5f472785fed770da77270300fb9ee5d7763ba7ac (patch) | |
tree | 1c2a4ad686df502345a58f8bfc5a728e6d7e5a0d /activerecord/test | |
parent | 984ce0cf9acf6e5bae4e95b87d6a9545579464ef (diff) | |
download | rails-5f472785fed770da77270300fb9ee5d7763ba7ac.tar.gz rails-5f472785fed770da77270300fb9ee5d7763ba7ac.tar.bz2 rails-5f472785fed770da77270300fb9ee5d7763ba7ac.zip |
allow an association as a scope parameter
#4321
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/validations/uniqueness_validation_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations/uniqueness_validation_test.rb b/activerecord/test/cases/validations/uniqueness_validation_test.rb index 327830096b..44c2812bff 100644 --- a/activerecord/test/cases/validations/uniqueness_validation_test.rb +++ b/activerecord/test/cases/validations/uniqueness_validation_test.rb @@ -92,6 +92,18 @@ class UniquenessValidationTest < ActiveRecord::TestCase assert r3.valid?, "Saving r3" end + def test_validate_uniqueness_with_object_scope + Reply.validates_uniqueness_of(:content, :scope => :topic) + + t = Topic.create("title" => "I'm unique!") + + r1 = t.replies.create "title" => "r1", "content" => "hello world" + assert r1.valid?, "Saving r1" + + r2 = t.replies.create "title" => "r2", "content" => "hello world" + assert !r2.valid?, "Saving r2 first time" + end + def test_validate_uniqueness_scoped_to_defining_class t = Topic.create("title" => "What, me worry?") |