FIX: when subcategories with the same name exist, filtering by tags might use the wrong subcategory

This commit is contained in:
Neil Lalonde 2016-11-02 15:29:33 -04:00
parent 61069bf378
commit 764a572070
2 changed files with 14 additions and 1 deletions

View File

@ -270,7 +270,7 @@ class TagsController < ::ApplicationController
page: params[:page],
topic_ids: param_to_integer_list(:topic_ids),
exclude_category_ids: params[:exclude_category_ids],
category: params[:category],
category: @filter_on_category ? @filter_on_category.id : params[:category],
order: params[:order],
ascending: params[:ascending],
min_posts: params[:min_posts],

View File

@ -68,6 +68,19 @@ describe TagsController do
xhr :get, :show_latest, tag_id: tag.name, category: 'none', parent_category: category.slug
expect(response).to be_success
end
it "can handle subcategories with the same name" do
category2 = Fabricate(:category)
subcategory2 = Fabricate(:category,
parent_category_id: category2.id,
name: subcategory.name,
slug: subcategory.slug
)
t = Fabricate(:topic, category_id: subcategory2.id, tags: [other_tag])
xhr :get, :show_latest, tag_id: other_tag.name, category: subcategory2.slug, parent_category: category2.slug
expect(response).to be_success
expect(assigns(:list).topics).to include(t)
end
end
end