show monthly top topics on 404 page

This commit is contained in:
Arpit Jalan 2016-02-24 13:26:48 +05:30
parent 12b5821d79
commit d77511319e
2 changed files with 2 additions and 1 deletions

View File

@ -454,7 +454,7 @@ class ApplicationController < ActionController::Base
def build_not_found_page(status=404, layout=false) def build_not_found_page(status=404, layout=false)
category_topic_ids = Category.pluck(:topic_id).compact category_topic_ids = Category.pluck(:topic_id).compact
@container_class = "wrap not-found-container" @container_class = "wrap not-found-container"
@top_viewed = Topic.where.not(id: category_topic_ids).top_viewed(10) @top_viewed = TopicQuery.new(nil, {except_topic_ids: category_topic_ids}).list_top_for("monthly").topics.first(10)
@recent = Topic.where.not(id: category_topic_ids).recent(10) @recent = Topic.where.not(id: category_topic_ids).recent(10)
@slug = params[:slug].class == String ? params[:slug] : '' @slug = params[:slug].class == String ? params[:slug] : ''
@slug = (params[:id].class == String ? params[:id] : '') if @slug.blank? @slug = (params[:id].class == String ? params[:id] : '') if @slug.blank?

View File

@ -1232,6 +1232,7 @@ describe UsersController do
guardian = Guardian.new(user) guardian = Guardian.new(user)
guardian.stubs(:ensure_can_edit!).with(user).raises(Discourse::InvalidAccess.new) guardian.stubs(:ensure_can_edit!).with(user).raises(Discourse::InvalidAccess.new)
Guardian.stubs(new: guardian).with(user) Guardian.stubs(new: guardian).with(user)
Guardian.stubs(new: guardian).with(nil)
put :update, username: user.username, name: 'Jim Tom' put :update, username: user.username, name: 'Jim Tom'