UX: Improve category filtering and include subcategories

* category_filtering
  1. report_top_referred_topics
  2. report_top_traffic_sources
  3. report_post_edit
* category_filtering with subcategory topics
  1. report_top_referred_topics
  2. report_top_traffic_sources
  3. report_post_edit
  4. report_posts
  5. report_topics
  6. report_topics_with_no_response
* category_filtering tests (without subcategory topics)
  1. report_posts
  2. report_topics_with_no_response
* subcategory topics tests `in_category_and_subcategories` in `topic_spec.rb`
  1. `in_category_and_subcategories` in `topic_spec.rb`
  2. topics, posts, flags and topics_with_no_response in `report_spec.rb`
This commit is contained in:
Misaka 0x4e21
2018-08-10 08:50:05 +08:00
committed by Sam
parent ef4b9f98c1
commit 6db623ef6b
6 changed files with 175 additions and 32 deletions

View File

@ -1366,6 +1366,22 @@ describe Topic do
expect(Topic.visible).to include c
end
end
describe '#in_category_and_subcategories' do
it 'returns topics in a category and its subcategories' do
c1 = Fabricate(:category)
c2 = Fabricate(:category, parent_category_id: c1.id)
c3 = Fabricate(:category)
t1 = Fabricate(:topic, category_id: c1.id)
t2 = Fabricate(:topic, category_id: c2.id)
t3 = Fabricate(:topic, category_id: c3.id)
expect(Topic.in_category_and_subcategories(c1.id)).not_to include(t3)
expect(Topic.in_category_and_subcategories(c1.id)).to include(t2)
expect(Topic.in_category_and_subcategories(c1.id)).to include(t1)
end
end
end
describe '#private_topic_timer' do