not use unnecessary instance variable at unit message test
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11199 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0f832e0d76
commit
10c96dba8b
|
@ -47,13 +47,13 @@ class MessageTest < ActiveSupport::TestCase
|
|||
def test_reply
|
||||
topics_count = @board.topics_count
|
||||
messages_count = @board.messages_count
|
||||
@message = Message.find(1)
|
||||
replies_count = @message.replies_count
|
||||
message = Message.find(1)
|
||||
replies_count = message.replies_count
|
||||
|
||||
reply_author = User.find(2)
|
||||
reply = Message.new(:board => @board, :subject => 'Test reply',
|
||||
:content => 'Test reply content',
|
||||
:parent => @message, :author => reply_author)
|
||||
:parent => message, :author => reply_author)
|
||||
assert reply.save
|
||||
@board.reload
|
||||
# same topics count
|
||||
|
@ -61,42 +61,42 @@ class MessageTest < ActiveSupport::TestCase
|
|||
# messages count incremented
|
||||
assert_equal messages_count+1, @board[:messages_count]
|
||||
assert_equal reply, @board.last_message
|
||||
@message.reload
|
||||
message.reload
|
||||
# replies count incremented
|
||||
assert_equal replies_count+1, @message[:replies_count]
|
||||
assert_equal reply, @message.last_reply
|
||||
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)
|
||||
assert message.watched_by?(reply_author)
|
||||
end
|
||||
|
||||
def test_cannot_reply_to_locked_topic
|
||||
topics_count = @board.topics_count
|
||||
messages_count = @board.messages_count
|
||||
@message = Message.find(1)
|
||||
replies_count = @message.replies_count
|
||||
assert_equal false, @message.locked
|
||||
@message.locked = true
|
||||
assert @message.save
|
||||
assert_equal true, @message.locked
|
||||
message = Message.find(1)
|
||||
replies_count = message.replies_count
|
||||
assert_equal false, message.locked
|
||||
message.locked = true
|
||||
assert message.save
|
||||
assert_equal true, message.locked
|
||||
|
||||
reply_author = User.find(2)
|
||||
reply = Message.new(:board => @board, :subject => 'Test reply',
|
||||
:content => 'Test reply content',
|
||||
:parent => @message, :author => reply_author)
|
||||
:parent => message, :author => reply_author)
|
||||
reply.save
|
||||
assert_equal 1, reply.errors.count
|
||||
end
|
||||
|
||||
def test_moving_message_should_update_counters
|
||||
@message = Message.find(1)
|
||||
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
|
||||
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)
|
||||
assert_difference 'Board.find(2).messages_count', (1 + message.replies_count) do
|
||||
message.update_attributes(:board_id => 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue