From 28864e74bcb3a07a50c7ee945d76dbc3d5f3d4e5 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 30 Mar 2015 11:40:44 -0400 Subject: [PATCH] FIX: Don't show the filter title on the default route --- app/controllers/list_controller.rb | 5 +++-- spec/controllers/list_controller_spec.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index 55bdac73f1b..bef7a75a0dc 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -50,7 +50,7 @@ class ListController < ApplicationController ].flatten # Create our filters - Discourse.filters.each do |filter| + Discourse.filters.each_with_index do |filter, idx| define_method(filter) do |options = nil| list_opts = build_topic_list_options list_opts.merge!(options) if options @@ -68,7 +68,8 @@ class ListController < ApplicationController @description = SiteSetting.site_description @rss = filter - if use_crawler_layout? + # Note the first is the default and we don't add a title + if idx > 0 && use_crawler_layout? filter_title = I18n.t("js.filters.#{filter.to_s}.title") if list_opts[:category] @title = I18n.t('js.filters.with_category', filter: filter_title, category: Category.find(list_opts[:category]).name) diff --git a/spec/controllers/list_controller_spec.rb b/spec/controllers/list_controller_spec.rb index 05ec93c3a8c..6f55de5b607 100644 --- a/spec/controllers/list_controller_spec.rb +++ b/spec/controllers/list_controller_spec.rb @@ -11,6 +11,18 @@ describe ListController do SiteSetting.stubs(:top_menu).returns('latest,-video|new|unread|categories|category/beer') end + describe 'titles for crawler layout' do + it 'has no title for the default URL' do + xhr :get, Discourse.anonymous_filters[0], _escaped_fragment_: 'true' + expect(assigns(:title)).to be_blank + end + + it 'has a title for non-default URLs' do + xhr :get, Discourse.anonymous_filters[1], _escaped_fragment_: 'true' + expect(assigns(:title)).to be_present + end + end + describe 'indexes' do (Discourse.anonymous_filters - [:categories]).each do |filter|