diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-09-26 22:40:51 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-09-26 22:40:51 +0000 |
commit | 54adccda08403d8ad4df7b4d20040bfb421bc738 (patch) | |
tree | fb35062cdaa231073ae77aef1e78102dbc352cd8 | |
parent | 1d738cab80b497f13ef6cfca1a658c6400609698 (diff) | |
download | rails-54adccda08403d8ad4df7b4d20040bfb421bc738.tar.gz rails-54adccda08403d8ad4df7b4d20040bfb421bc738.tar.bz2 rails-54adccda08403d8ad4df7b4d20040bfb421bc738.zip |
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
-rwxr-xr-x | activerecord/test/validations_test.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index afd11c6d62..32beb7d606 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -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
\ No newline at end of file +end |