BUGFIX: JSON requests don't exclude categories from filters
This commit is contained in:
parent
59253c937e
commit
ae401f0dc7
|
@ -201,7 +201,7 @@ class ListController < ApplicationController
|
|||
def build_topic_list_options
|
||||
# html format means we need to parse exclude category (aka filter) from the site options top menu
|
||||
menu_items = SiteSetting.top_menu_items
|
||||
menu_item = menu_items.select { |item| item.query_should_exclude_category?(action_name, params[:format]) }.first
|
||||
menu_item = menu_items.select { |item| item.query_should_exclude_category?(action_name) }.first
|
||||
|
||||
# exclude_category = 1. from params / 2. parsed from top menu / 3. nil
|
||||
options = {
|
||||
|
|
|
@ -43,12 +43,8 @@ class TopMenuItem
|
|||
name.split('/')[1]
|
||||
end
|
||||
|
||||
def query_should_exclude_category?(action_name, format)
|
||||
if format.blank? || format == "html"
|
||||
def query_should_exclude_category?(action_name)
|
||||
matches_action?(action_name) && has_filter?
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def matches_action?(action_name)
|
||||
|
|
|
@ -59,11 +59,7 @@ describe TopMenuItem do
|
|||
end
|
||||
|
||||
it "excludes category" do
|
||||
expect(items[0].query_should_exclude_category?(nil, nil)).to be_true
|
||||
end
|
||||
|
||||
it "does not exclude for json format" do
|
||||
expect(items[0].query_should_exclude_category?(nil, 'json')).to be_false
|
||||
expect(items[0].query_should_exclude_category?(nil)).to be_true
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue