mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
r3603@asus: jeremy | 2005-09-26 19:10:00 -0700
Add unit tests for nil assigned to validates_size_of :attr, :within git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2354 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
1d738cab80
commit
54adccda08
1 changed files with 10 additions and 5 deletions
|
@ -396,15 +396,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
def test_validates_length_of_using_within
|
||||
Topic.validates_length_of(:title, :content, :within => 3..5)
|
||||
|
||||
t = Topic.create("title" => "a!", "content" => "I'm ooooooooh so very long")
|
||||
assert !t.save
|
||||
|
||||
t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long")
|
||||
assert !t.valid?
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too long (max is 5 characters)", t.errors.on(:content)
|
||||
|
||||
t.title = nil
|
||||
t.content = nil
|
||||
assert !t.valid?
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:content)
|
||||
|
||||
t.title = "abe"
|
||||
t.content = "mad"
|
||||
assert t.save
|
||||
assert t.valid?
|
||||
end
|
||||
|
||||
def test_optionally_validates_length_of_using_within
|
||||
|
@ -801,4 +806,4 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
r.topic = Topic.find :first
|
||||
assert r.valid?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue