diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-01 06:46:40 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-01 06:46:40 +0000 |
commit | ba8e0a846f0e5ee84a16a5e128106883f6d10b71 (patch) | |
tree | 40190ba87808b0af4e3f6359ac713d85d9cf0592 /activerecord/test/cases | |
parent | c3df9bfad2b7e560fcf8c5fb4b5ddc086d83a634 (diff) | |
download | rails-ba8e0a846f0e5ee84a16a5e128106883f6d10b71.tar.gz rails-ba8e0a846f0e5ee84a16a5e128106883f6d10b71.tar.bz2 rails-ba8e0a846f0e5ee84a16a5e128106883f6d10b71.zip |
Ruby 1.9 compat: work around YAML serialization error exposed by validations tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9192 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-x | activerecord/test/cases/validations_test.rb | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 1bcd72c71f..97ac22eaf3 100755 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -8,12 +8,15 @@ require 'models/warehouse_thing' # The following methods in Topic are used in test_conditional_validation_* class Topic + has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" + has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" + def condition_is_true - return true + true end def condition_is_true_but_its_not - return false + false end end @@ -34,11 +37,6 @@ end class SillyUniqueReply < UniqueReply end -class Topic < ActiveRecord::Base - has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" - has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" -end - class Wizard < ActiveRecord::Base self.abstract_class = true @@ -55,6 +53,7 @@ end class Thaumaturgist < IneptWizard end + class ValidationsTest < ActiveRecord::TestCase fixtures :topics, :developers, 'warehouse-things' @@ -958,19 +957,22 @@ class ValidationsTest < ActiveRecord::TestCase def test_optionally_validates_length_of_using_within_utf8 with_kcode('UTF8') do - Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true + Topic.validates_length_of :title, :within => 3..5, :allow_nil => true - t = Topic.create('title' => '一二三', 'content' => '一二三四五') - assert t.valid? + t = Topic.create(:title => "一二三四五") + assert t.valid?, t.errors.inspect + + t = Topic.create(:title => "一二三") + assert t.valid?, t.errors.inspect t.title = nil - assert t.valid? + assert t.valid?, t.errors.inspect end end def test_optionally_validates_length_of_using_within_on_create_utf8 with_kcode('UTF8') do - Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "長すぎます: %d" + Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: %d" t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever") assert !t.save @@ -993,7 +995,7 @@ class ValidationsTest < ActiveRecord::TestCase def test_optionally_validates_length_of_using_within_on_update_utf8 with_kcode('UTF8') do - Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "短すぎます: %d" + Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: %d" t = Topic.create("title" => "一二三4", "content" => "whatever") assert !t.save @@ -1004,12 +1006,11 @@ class ValidationsTest < ActiveRecord::TestCase assert t.errors.on(:title) assert_equal "短すぎます: 5", t.errors[:title] - t.title = "valid" - t.content = "一二三四五六七八九十A" + t.title = "一二三四五六七八九十A" assert !t.save - assert t.errors.on(:content) + assert t.errors.on(:title) - t.content = "一二345" + t.title = "一二345" assert t.save end end |