Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9192

Show
Ignore:
Timestamp:
04/01/08 06:46:40 (3 months ago)
Author:
bitsweat
Message:

Ruby 1.9 compat: work around YAML serialization error exposed by validations tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/test/cases/validations_test.rb

    r9168 r9192  
    99# The following methods in Topic are used in test_conditional_validation_* 
    1010class Topic 
     11  has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 
     12  has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 
     13 
    1114  def condition_is_true 
    12     return true 
     15    true 
    1316  end 
    1417 
    1518  def condition_is_true_but_its_not 
    16     return false 
     19    false 
    1720  end 
    1821end 
     
    3538end 
    3639 
    37 class Topic < ActiveRecord::Base 
    38   has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 
    39   has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 
    40 end 
    41  
    4240class Wizard < ActiveRecord::Base 
    4341  self.abstract_class = true 
     
    5553class Thaumaturgist < IneptWizard 
    5654end 
     55 
    5756 
    5857class ValidationsTest < ActiveRecord::TestCase 
     
    961960  def test_optionally_validates_length_of_using_within_utf8 
    962961    with_kcode('UTF8') do 
    963       Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true 
    964  
    965       t = Topic.create('title' => '䞀二䞉', 'content' => '䞀二䞉四五') 
    966       assert t.valid? 
     962      Topic.validates_length_of :title, :within => 3..5, :allow_nil => true 
     963 
     964      t = Topic.create(:title => "䞀二䞉四五") 
     965      assert t.valid?, t.errors.inspect 
     966 
     967      t = Topic.create(:title => "䞀二䞉") 
     968      assert t.valid?, t.errors.inspect 
    967969 
    968970      t.title = nil 
    969       assert t.valid? 
     971      assert t.valid?, t.errors.inspect 
    970972    end 
    971973  end 
     
    973975  def test_optionally_validates_length_of_using_within_on_create_utf8 
    974976    with_kcode('UTF8') do 
    975       Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "長すぎたす: %d" 
     977      Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎたす: %d" 
    976978 
    977979      t = Topic.create("title" => "䞀二䞉四五å 
     
    10031005  def test_optionally_validates_length_of_using_within_on_update_utf8 
    10041006    with_kcode('UTF8') do 
    1005       Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "短すぎたす: %d" 
     1007      Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎたす: %d" 
    10061008 
    10071009      t = Topic.create("title" => "䞀二䞉4", "content" => "whatever") 
     
    10141016      assert_equal "短すぎたす: 5", t.errors[:title] 
    10151017 
    1016       t.title = "valid" 
    1017       t.content = "䞀二䞉四五å 
     1018      t.title = "䞀二䞉四五å 
    10181019­äžƒå 
    10191020«ä¹åA" 
    10201021      assert !t.save 
    1021       assert t.errors.on(:content
    1022  
    1023       t.content = "䞀二345" 
     1022      assert t.errors.on(:title
     1023 
     1024      t.title = "䞀二345" 
    10241025      assert t.save 
    10251026    end 
  • trunk/activerecord/test/models/topic.rb

    r9084 r9192  
    2727  named_scope :named_extension, :extend => NamedExtension 
    2828  named_scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne] 
    29    
     29 
    3030  has_many :replies, :dependent => :destroy, :foreign_key => "parent_id" 
    3131  serialize :content 
     
    4242    id 
    4343  end 
    44  
    4544 
    4645  protected