Project

General

Profile

Patch #43289 » fix-news-comments_count-v2.patch

Go MAEDA, 2025-10-05 03:41

View differences:

test/unit/comment_test.rb
27 27
  end
28 28

  
29 29
  def test_create
30
    comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment")
31
    assert comment.save
32
    @news.reload
33
    assert_equal 2, @news.comments_count
30
    assert_difference '@news.comments_count', 1 do
31
      comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment")
32
      assert comment.save
33
      @news.reload
34
    end
34 35
  end
35 36

  
36 37
  def test_create_should_send_notification
......
50 51
  end
51 52

  
52 53
  def test_destroy
53
    comment = Comment.find(1)
54
    assert comment.destroy
55
    @news.reload
56
    assert_equal 0, @news.comments_count
54
    assert_difference '@news.comments_count', -1 do
55
      comment = Comment.find(1)
56
      assert comment.destroy
57
      @news.reload
58
    end
57 59
  end
58 60
end
(4-4/4)