From ca166b30e1b223c7f3aba3befc894a8597362592 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 5 Apr 2009 10:08:11 +0000 Subject: Adds the ability to move threads between project forums (#2452). 'Edit message' permission is required. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2649 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/message_test.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/unit/message_test.rb') diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb index b907cfef3..bc9bd5fd3 100644 --- a/test/unit/message_test.rb +++ b/test/unit/message_test.rb @@ -1,3 +1,20 @@ +# Redmine - project management software +# Copyright (C) 2006-2009 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + require File.dirname(__FILE__) + '/../test_helper' class MessageTest < Test::Unit::TestCase @@ -47,6 +64,23 @@ class MessageTest < Test::Unit::TestCase assert @message.watched_by?(reply_author) end + def test_moving_message_should_update_counters + @message = Message.find(1) + assert_no_difference 'Message.count' do + # Previous board + assert_difference 'Board.find(1).topics_count', -1 do + assert_difference 'Board.find(1).messages_count', -(1 + @message.replies_count) do + # New board + assert_difference 'Board.find(2).topics_count' do + assert_difference 'Board.find(2).messages_count', (1 + @message.replies_count) do + @message.update_attributes(:board_id => 2) + end + end + end + end + end + end + def test_destroy_topic message = Message.find(1) board = message.board -- cgit v1.2.3