From ccb0a92fa2ba0bf7be50033090c3a861e6d907be Mon Sep 17 00:00:00 2001 From: Arthur Klepchukov Date: Sat, 7 Mar 2009 13:52:17 +0000 Subject: Ensure validates_uniqueness_of considers limit on the field. [#1042 state:resolved] Signed-off-by: Pratik Naik --- activerecord/test/cases/validations_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activerecord/test/cases/validations_test.rb') diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 8ef5dc09c5..f87168860f 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -8,6 +8,7 @@ require 'models/warehouse_thing' require 'models/guid' require 'models/owner' require 'models/pet' +require 'models/event' # The following methods in Topic are used in test_conditional_validation_* class Topic @@ -530,6 +531,14 @@ class ValidationsTest < ActiveRecord::TestCase end end + def test_validate_uniqueness_with_limit + # Event.title is limited to 5 characters + e1 = Event.create(:title => "abcde") + assert e1.valid?, "Could not create an event with a unique, 5 character title" + e2 = Event.create(:title => "abcdefgh") + assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique" + end + def test_validate_straight_inheritance_uniqueness w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork") assert w1.valid?, "Saving w1" -- cgit v1.2.3