@topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
- @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
+ @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all(
:include => [:author, {:last_reply => :author}],
:limit => @topic_pages.items_per_page,
- :offset => @topic_pages.current.offset
+ :offset => @topic_pages.current.offset)
@message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr?
}
assert_not_nil assigns(:topics)
end
+ def test_show_should_display_sticky_messages_first
+ Message.update_all(:sticky => 0)
+ Message.update_all({:sticky => 1}, {:id => 1})
+
+ get :show, :project_id => 1, :id => 1
+ assert_response :success
+
+ topics = assigns(:topics)
+ assert_not_nil topics
+ assert topics.size > 1, "topics size was #{topics.size}"
+ assert topics.first.sticky?
+ assert topics.first.updated_on < topics.second.updated_on
+ end
+
def test_show_with_permission_should_display_the_new_message_form
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 1