Adds pagination to forum messages (#4664).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3373 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2010-02-06 12:54:13 +00:00
parent 2ad8242ae7
commit 8fb29d4d21
6 changed files with 46 additions and 12 deletions
+18 -1
View File
@@ -47,6 +47,22 @@ class MessagesControllerTest < ActionController::TestCase
assert_not_nil assigns(:topic)
end
def test_show_with_pagination
message = Message.find(1)
assert_difference 'Message.count', 30 do
30.times do
message.children << Message.new(:subject => 'Reply', :content => 'Reply body', :author_id => 2, :board_id => 1)
end
end
get :show, :board_id => 1, :id => 1, :r => message.children.last(:order => 'id').id
assert_response :success
assert_template 'show'
replies = assigns(:replies)
assert_not_nil replies
assert !replies.include?(message.children.first(:order => 'id'))
assert replies.include?(message.children.last(:order => 'id'))
end
def test_show_with_reply_permission
@request.session[:user_id] = 2
get :show, :board_id => 1, :id => 1
@@ -143,7 +159,8 @@ class MessagesControllerTest < ActionController::TestCase
def test_reply
@request.session[:user_id] = 2
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
assert_redirected_to 'boards/1/topics/1'
reply = Message.find(:first, :order => 'id DESC')
assert_redirected_to "boards/1/topics/1?r=#{reply.id}"
assert Message.find_by_subject('Test reply')
end