Merge pull request #4034 from techAPJ/404

show monthly top topics on 404 page
This commit is contained in:
Jeff Atwood 2016-02-24 01:10:50 -08:00
commit f259d7a7b9
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'