diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-14 20:53:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-14 20:53:14 +0000 |
commit | 46756cbd5646286a96df9058373324454add49a4 (patch) | |
tree | 971e3dbe40cbd7db875a416d7e524e7f45bbb71b | |
parent | 48205aa7d98275c8effbc21750449cb2461b0e57 (diff) | |
download | redmine-46756cbd5646286a96df9058373324454add49a4.tar.gz redmine-46756cbd5646286a96df9058373324454add49a4.zip |
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
-rw-r--r-- | app/controllers/news_controller.rb | 2 | ||||
-rw-r--r-- | test/functional/news_controller_test.rb | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 50c0489f4..e1ef1c3ec 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -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 diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 8a7586285..7d342605f 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -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 |