Sha256: 033bb3b9b74fa5e4bf96ed117163400b738d87b1956d85f60b33d92960aafa3b
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# -*- coding: utf-8 -*- require "cases/helper" require 'models/owner' require 'models/pet' class LengthValidationTest < ActiveRecord::TestCase fixtures :owners repair_validations(Owner) def test_validates_size_of_association repair_validations Owner do assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } o = Owner.new('name' => 'nopets') assert !o.save assert o.errors[:pets].any? o.pets.build('name' => 'apet') assert o.valid? end end def test_validates_size_of_association_using_within repair_validations Owner do assert_nothing_raised { Owner.validates_size_of :pets, :within => 1..2 } o = Owner.new('name' => 'nopets') assert !o.save assert o.errors[:pets].any? o.pets.build('name' => 'apet') assert o.valid? 2.times { o.pets.build('name' => 'apet') } assert !o.save assert o.errors[:pets].any? end end def test_validates_size_of_association_utf8 repair_validations Owner do assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } o = Owner.new('name' => 'あいうえおかきくけこ') assert !o.save assert o.errors[:pets].any? o.pets.build('name' => 'あいうえおかきくけこ') assert o.valid? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ibm_db-3.0.5-x86-mingw32 | test/cases/validations/length_validation_test.rb |
ibm_db-3.0.5 | test/cases/validations/length_validation_test.rb |