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

Ticket #6896: counter_cache_overwrite_failing_tests.diff

File counter_cache_overwrite_failing_tests.diff, 1.2 kB (added by dcmanges, 3 years ago)
  • test/associations_test.rb

    old new  
    11261126    assert_equal 0, Topic.find(t1.id).replies.size 
    11271127    assert_equal 0, Topic.find(t2.id).replies.size 
    11281128  end 
     1129   
     1130  def test_belongs_to_counter_after_save 
     1131    topic = Topic.create("title" => "monday night") 
     1132    topic.replies.create("title" => "re: monday night", "content" => "football") 
     1133    assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") 
    11291134 
     1135    topic.save 
     1136    assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") 
     1137  end 
     1138 
     1139  def test_belongs_to_counter_after_update_attributes 
     1140    topic = Topic.create("title" => "37s") 
     1141    topic.replies.create("title" => "re: 37s", "content" => "rails") 
     1142    assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") 
     1143 
     1144    topic.update_attributes("title" => "37signals") 
     1145    assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") 
     1146  end 
     1147 
    11301148  def test_assignment_before_parent_saved 
    11311149    client = Client.find(:first) 
    11321150    apple = Firm.new("name" => "Apple")