@@ -58,7 +58,7 class NewsController < ApplicationController | |||||
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def show |
|
60 | def show | |
61 | @comments = @news.comments |
|
61 | @comments = @news.comments.to_a | |
62 | @comments.reverse! if User.current.wants_comments_in_reverse_order? |
|
62 | @comments.reverse! if User.current.wants_comments_in_reverse_order? | |
63 | end |
|
63 | end | |
64 |
|
64 |
@@ -63,6 +63,17 class NewsControllerTest < ActionController::TestCase | |||||
63 | assert_tag 'a', :content => attachment.filename |
|
63 | assert_tag 'a', :content => attachment.filename | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
|
66 | def test_show_with_comments_in_reverse_order | |||
|
67 | user = User.find(1) | |||
|
68 | user.pref[:comments_sorting] = 'desc' | |||
|
69 | user.pref.save! | |||
|
70 | ||||
|
71 | @request.session[:user_id] = 1 | |||
|
72 | get :show, :id => 1 | |||
|
73 | assert_response :success | |||
|
74 | assert_equal News.find(1).comments.to_a.sort_by(&:created_on).reverse, assigns(:comments) | |||
|
75 | end | |||
|
76 | ||||
66 | def test_show_not_found |
|
77 | def test_show_not_found | |
67 | get :show, :id => 999 |
|
78 | get :show, :id => 999 | |
68 | assert_response 404 |
|
79 | assert_response 404 |
General Comments 0
You need to be logged in to leave comments.
Login now