1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-06 09:03:25 +00:00

Fixed 500 error when displaying a news with comments in reverse order (#18332).

git-svn-id: http://svn.redmine.org/redmine/trunk@13595 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-11-14 20:53:14 +00:00
parent 48205aa7d9
commit 46756cbd56
2 changed files with 12 additions and 1 deletions

View File

@ -58,7 +58,7 @@ class NewsController < ApplicationController
end
def show
@comments = @news.comments
@comments = @news.comments.to_a
@comments.reverse! if User.current.wants_comments_in_reverse_order?
end

View File

@ -63,6 +63,17 @@ class NewsControllerTest < ActionController::TestCase
assert_tag 'a', :content => attachment.filename
end
def test_show_with_comments_in_reverse_order
user = User.find(1)
user.pref[:comments_sorting] = 'desc'
user.pref.save!
@request.session[:user_id] = 1
get :show, :id => 1
assert_response :success
assert_equal News.find(1).comments.to_a.sort_by(&:created_on).reverse, assigns(:comments)
end
def test_show_not_found
get :show, :id => 999
assert_response 404