BUGFIX: JSON requests don't exclude categories from filters

This commit is contained in:
Régis Hanol 2014-01-31 14:36:00 +01:00
parent 59253c937e
commit ae401f0dc7
3 changed files with 5 additions and 13 deletions

View File

@ -201,7 +201,7 @@ class ListController < ApplicationController
def build_topic_list_options def build_topic_list_options
# html format means we need to parse exclude category (aka filter) from the site options top menu # html format means we need to parse exclude category (aka filter) from the site options top menu
menu_items = SiteSetting.top_menu_items 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 # exclude_category = 1. from params / 2. parsed from top menu / 3. nil
options = { options = {

View File

@ -43,12 +43,8 @@ class TopMenuItem
name.split('/')[1] name.split('/')[1]
end end
def query_should_exclude_category?(action_name, format) def query_should_exclude_category?(action_name)
if format.blank? || format == "html"
matches_action?(action_name) && has_filter? matches_action?(action_name) && has_filter?
else
false
end
end end
def matches_action?(action_name) def matches_action?(action_name)

View File

@ -59,11 +59,7 @@ describe TopMenuItem do
end end
it "excludes category" do it "excludes category" do
expect(items[0].query_should_exclude_category?(nil, nil)).to be_true expect(items[0].query_should_exclude_category?(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
end end
end end
end end