mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 14:43:21 +08:00
FIX: Don't show the filter title on the default route
This commit is contained in:
parent
10b8eca9a6
commit
28864e74bc
|
@ -50,7 +50,7 @@ class ListController < ApplicationController
|
||||||
].flatten
|
].flatten
|
||||||
|
|
||||||
# Create our filters
|
# Create our filters
|
||||||
Discourse.filters.each do |filter|
|
Discourse.filters.each_with_index do |filter, idx|
|
||||||
define_method(filter) do |options = nil|
|
define_method(filter) do |options = nil|
|
||||||
list_opts = build_topic_list_options
|
list_opts = build_topic_list_options
|
||||||
list_opts.merge!(options) if options
|
list_opts.merge!(options) if options
|
||||||
|
@ -68,7 +68,8 @@ class ListController < ApplicationController
|
||||||
@description = SiteSetting.site_description
|
@description = SiteSetting.site_description
|
||||||
@rss = filter
|
@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")
|
filter_title = I18n.t("js.filters.#{filter.to_s}.title")
|
||||||
if list_opts[:category]
|
if list_opts[:category]
|
||||||
@title = I18n.t('js.filters.with_category', filter: filter_title, category: Category.find(list_opts[:category]).name)
|
@title = I18n.t('js.filters.with_category', filter: filter_title, category: Category.find(list_opts[:category]).name)
|
||||||
|
|
|
@ -11,6 +11,18 @@ describe ListController do
|
||||||
SiteSetting.stubs(:top_menu).returns('latest,-video|new|unread|categories|category/beer')
|
SiteSetting.stubs(:top_menu).returns('latest,-video|new|unread|categories|category/beer')
|
||||||
end
|
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
|
describe 'indexes' do
|
||||||
|
|
||||||
(Discourse.anonymous_filters - [:categories]).each do |filter|
|
(Discourse.anonymous_filters - [:categories]).each do |filter|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user