From 7ba28d434ceb0401f937e77f19d1c31e2a43f1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 20 Dec 2011 18:33:28 +0100 Subject: Remove dead code from AMo. --- .../cases/validations/length_validation_test.rb | 84 ++++++++++------------ 1 file changed, 37 insertions(+), 47 deletions(-) (limited to 'activemodel/test/cases') diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb index 44048a9c1d..aa86d9d959 100644 --- a/activemodel/test/cases/validations/length_validation_test.rb +++ b/activemodel/test/cases/validations/length_validation_test.rb @@ -260,74 +260,64 @@ class LengthValidationTest < ActiveModel::TestCase end def test_validates_length_of_using_minimum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :minimum => 5 + Topic.validates_length_of :title, :minimum => 5 - t = Topic.new("title" => "一二三四五", "content" => "whatever") - assert t.valid? + t = Topic.new("title" => "一二三四五", "content" => "whatever") + assert t.valid? - t.title = "一二三四" - assert t.invalid? - assert t.errors[:title].any? - assert_equal ["is too short (minimum is 5 characters)"], t.errors["title"] - end + t.title = "一二三四" + assert t.invalid? + assert t.errors[:title].any? + assert_equal ["is too short (minimum is 5 characters)"], t.errors["title"] end def test_validates_length_of_using_maximum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :maximum => 5 + Topic.validates_length_of :title, :maximum => 5 - t = Topic.new("title" => "一二三四五", "content" => "whatever") - assert t.valid? + t = Topic.new("title" => "一二三四五", "content" => "whatever") + assert t.valid? - t.title = "一二34五六" - assert t.invalid? - assert t.errors[:title].any? - assert_equal ["is too long (maximum is 5 characters)"], t.errors["title"] - end + t.title = "一二34五六" + assert t.invalid? + assert t.errors[:title].any? + assert_equal ["is too long (maximum is 5 characters)"], t.errors["title"] end def test_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of(:title, :content, :within => 3..5) - - t = Topic.new("title" => "一二", "content" => "12三四五六七") - assert t.invalid? - assert_equal ["is too short (minimum is 3 characters)"], t.errors[:title] - assert_equal ["is too long (maximum is 5 characters)"], t.errors[:content] - t.title = "一二三" - t.content = "12三" - assert t.valid? - end + Topic.validates_length_of(:title, :content, :within => 3..5) + + t = Topic.new("title" => "一二", "content" => "12三四五六七") + assert t.invalid? + assert_equal ["is too short (minimum is 3 characters)"], t.errors[:title] + assert_equal ["is too long (maximum is 5 characters)"], t.errors[:content] + t.title = "一二三" + t.content = "12三" + assert t.valid? end def test_optionally_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 3..5, :allow_nil => true + Topic.validates_length_of :title, :within => 3..5, :allow_nil => true - t = Topic.new(:title => "一二三四五") - assert t.valid?, t.errors.inspect + t = Topic.new(:title => "一二三四五") + assert t.valid?, t.errors.inspect - t = Topic.new(:title => "一二三") - assert t.valid?, t.errors.inspect + t = Topic.new(:title => "一二三") + assert t.valid?, t.errors.inspect - t.title = nil - assert t.valid?, t.errors.inspect - end + t.title = nil + assert t.valid?, t.errors.inspect end def test_validates_length_of_using_is_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :is => 5 + Topic.validates_length_of :title, :is => 5 - t = Topic.new("title" => "一二345", "content" => "whatever") - assert t.valid? + t = Topic.new("title" => "一二345", "content" => "whatever") + assert t.valid? - t.title = "一二345六" - assert t.invalid? - assert t.errors[:title].any? - assert_equal ["is the wrong length (should be 5 characters)"], t.errors["title"] - end + t.title = "一二345六" + assert t.invalid? + assert t.errors[:title].any? + assert_equal ["is the wrong length (should be 5 characters)"], t.errors["title"] end def test_validates_length_of_with_block -- cgit v1.2.3