From 3ef7e5624b28f21fcc55614f96e6aff7b61dd70f Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 5 Oct 2025 08:27:54 +0000 Subject: [PATCH] Incorrect comments_count value in News fixture for news_001 (#43289). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@24028 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/fixtures/news.yml | 2 +- test/unit/comment_test.rb | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/fixtures/news.yml b/test/fixtures/news.yml index 9876065e1..ba4e42e69 100644 --- a/test/fixtures/news.yml +++ b/test/fixtures/news.yml @@ -10,7 +10,7 @@ news_001: Visit http://ecookbook.somenet.foo/ summary: First version was released... author_id: 2 - comments_count: 1 + comments_count: 2 news_002: created_on: 2006-07-19 22:42:58 +02:00 project_id: 1 diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index a41001a89..94bb7a4d9 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -27,10 +27,11 @@ class CommentTest < ActiveSupport::TestCase end def test_create - comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment") - assert comment.save - @news.reload - assert_equal 2, @news.comments_count + assert_difference '@news.comments_count', 1 do + comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment") + assert comment.save + @news.reload + end end def test_create_should_send_notification @@ -50,9 +51,10 @@ class CommentTest < ActiveSupport::TestCase end def test_destroy - comment = Comment.find(1) - assert comment.destroy - @news.reload - assert_equal 0, @news.comments_count + assert_difference '@news.comments_count', -1 do + comment = Comment.find(1) + assert comment.destroy + @news.reload + end end end