summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-19 15:32:52 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-19 15:32:52 +0000
commit16e09bfd774487d7b21e1b939f9b0321ad3a850a (patch)
treef1952dff78c37929699621a06a1de69adf3fda2c /test
parent9e7bce6a94626b4f96133bddc508192f2dfaff4f (diff)
downloadredmine-16e09bfd774487d7b21e1b939f9b0321ad3a850a.tar.gz
redmine-16e09bfd774487d7b21e1b939f9b0321ad3a850a.zip
Adds watch/unwatch functionality at forum topic level (#1912).
Users who create/reply a topic are automatically added as watchers but are now able to unwatch the topic. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1878 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/watchers.yml4
-rw-r--r--test/unit/message_test.rb15
2 files changed, 16 insertions, 3 deletions
diff --git a/test/fixtures/watchers.yml b/test/fixtures/watchers.yml
index a8c482955..6c8cdfb5e 100644
--- a/test/fixtures/watchers.yml
+++ b/test/fixtures/watchers.yml
@@ -3,4 +3,8 @@ watchers_001:
watchable_type: Issue
watchable_id: 2
user_id: 3
+watchers_002:
+ watchable_type: Message
+ watchable_id: 1
+ user_id: 1
\ No newline at end of file
diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb
index 82ed3fe13..6e8e8fb26 100644
--- a/test/unit/message_test.rb
+++ b/test/unit/message_test.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class MessageTest < Test::Unit::TestCase
- fixtures :projects, :boards, :messages
+ fixtures :projects, :boards, :messages, :users, :watchers
def setup
@board = Board.find(1)
@@ -20,6 +20,8 @@ class MessageTest < Test::Unit::TestCase
# messages count incremented
assert_equal messages_count+1, @board[:messages_count]
assert_equal message, @board.last_message
+ # author should be watching the message
+ assert message.watched_by?(@user)
end
def test_reply
@@ -28,7 +30,8 @@ class MessageTest < Test::Unit::TestCase
@message = Message.find(1)
replies_count = @message.replies_count
- reply = Message.new(:board => @board, :subject => 'Test reply', :content => 'Test reply content', :parent => @message, :author => @user)
+ reply_author = User.find(2)
+ reply = Message.new(:board => @board, :subject => 'Test reply', :content => 'Test reply content', :parent => @message, :author => reply_author)
assert reply.save
@board.reload
# same topics count
@@ -40,13 +43,18 @@ class MessageTest < Test::Unit::TestCase
# replies count incremented
assert_equal replies_count+1, @message[:replies_count]
assert_equal reply, @message.last_reply
+ # author should be watching the message
+ assert @message.watched_by?(reply_author)
end
def test_destroy_topic
message = Message.find(1)
board = message.board
topics_count, messages_count = board.topics_count, board.messages_count
- assert message.destroy
+
+ assert_difference('Watcher.count', -1) do
+ assert message.destroy
+ end
board.reload
# Replies deleted
@@ -54,6 +62,7 @@ class MessageTest < Test::Unit::TestCase
# Checks counters
assert_equal topics_count - 1, board.topics_count
assert_equal messages_count - 3, board.messages_count
+ # Watchers removed
end
def test_destroy_reply