[#775] Don't create a new journal on parent message on reply

This commit is contained in:
Holger Just 2012-01-31 15:06:11 +01:00
parent fb595ec7f9
commit 01fefe8d3b
2 changed files with 7 additions and 2 deletions

View File

@ -30,7 +30,8 @@ class Message < ActiveRecord::Base
{:id => msg.parent_id, :r => msg.id, :anchor => "message-#{msg.id}"}
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => msg.board_id
end),
:activity_find_options => { :include => { :board => :project } }
:activity_find_options => { :include => { :board => :project } },
:except => [:last_reply_id, :replies_count]
acts_as_searchable :columns => ['subject', 'content'],
:include => {:board => :project},

View File

@ -43,22 +43,27 @@ class MessageTest < ActiveSupport::TestCase
messages_count = @board.messages_count
@message = Message.find(1)
replies_count = @message.replies_count
journals_count = @message.journals.count
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
assert_equal topics_count, @board[:topics_count]
# messages count incremented
assert_equal messages_count+1, @board[:messages_count]
assert_equal reply, @board.last_message
@message.reload
# 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)
# journal count should be unchanged
assert_equal journals_count, @message.journals.count
end
def test_moving_message_should_update_counters
@ -146,6 +151,5 @@ class MessageTest < ActiveSupport::TestCase
message = Message.new(:board => @board, :subject => 'Test message', :content => 'Test message content', :author => @user)
assert message.save
end
end
end