mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:25:24 +08:00
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:
@ -15,6 +15,20 @@ describe Report do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'category filtering on subcategories' do
|
||||
before(:all) do
|
||||
c3 = Fabricate(:category, id: 3)
|
||||
c2 = Fabricate(:category, id: 2, parent_category_id: 3)
|
||||
Topic.find(c2.topic_id).delete
|
||||
Topic.find(c3.topic_id).delete
|
||||
end
|
||||
after(:all) do
|
||||
Category.where(id: 2).or(Category.where(id: 3)).destroy_all
|
||||
User.where("id > 0").destroy_all
|
||||
end
|
||||
include_examples 'category filtering'
|
||||
end
|
||||
|
||||
shared_examples 'with data x/y' do
|
||||
it "returns today's data" do
|
||||
expect(report.data.select { |v| v[:x].today? }).to be_present
|
||||
@ -717,6 +731,12 @@ describe Report do
|
||||
let(:report) { Report.find('flags', category_id: 2) }
|
||||
|
||||
include_examples 'category filtering'
|
||||
|
||||
context "on subcategories" do
|
||||
let(:report) { Report.find('flags', category_id: 3) }
|
||||
|
||||
include_examples 'category filtering on subcategories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -740,6 +760,12 @@ describe Report do
|
||||
let(:report) { Report.find('topics', category_id: 2) }
|
||||
|
||||
include_examples 'category filtering'
|
||||
|
||||
context "on subcategories" do
|
||||
let(:report) { Report.find('topics', category_id: 3) }
|
||||
|
||||
include_examples 'category filtering on subcategories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -777,4 +803,66 @@ describe Report do
|
||||
expect(report.error).to eq(:timeout)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'posts' do
|
||||
let(:report) { Report.find('posts') }
|
||||
|
||||
include_examples 'no data'
|
||||
|
||||
context 'with data' do
|
||||
include_examples 'with data x/y'
|
||||
|
||||
before(:each) do
|
||||
topic = Fabricate(:topic)
|
||||
topic_with_category_id = Fabricate(:topic, category_id: 2)
|
||||
Fabricate(:post, topic: topic)
|
||||
Fabricate(:post, topic: topic_with_category_id)
|
||||
Fabricate(:post, topic: topic)
|
||||
Fabricate(:post, created_at: 45.days.ago, topic: topic)
|
||||
end
|
||||
|
||||
context "with category filtering" do
|
||||
let(:report) { Report.find('posts', category_id: 2) }
|
||||
|
||||
include_examples 'category filtering'
|
||||
|
||||
context "on subcategories" do
|
||||
let(:report) { Report.find('posts', category_id: 3) }
|
||||
|
||||
include_examples 'category filtering on subcategories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: time_to_first_response
|
||||
|
||||
describe 'topics_with_no_response' do
|
||||
let(:report) { Report.find('topics_with_no_response') }
|
||||
|
||||
include_examples 'no data'
|
||||
|
||||
context 'with data' do
|
||||
include_examples 'with data x/y'
|
||||
|
||||
before(:each) do
|
||||
Fabricate(:topic, category_id: 2)
|
||||
Fabricate(:post, topic: Fabricate(:topic))
|
||||
Fabricate(:topic)
|
||||
Fabricate(:topic, created_at: 45.days.ago)
|
||||
end
|
||||
|
||||
context "with category filtering" do
|
||||
let(:report) { Report.find('topics_with_no_response', category_id: 2) }
|
||||
|
||||
include_examples 'category filtering'
|
||||
|
||||
context "on subcategories" do
|
||||
let(:report) { Report.find('topics_with_no_response', category_id: 3) }
|
||||
|
||||
include_examples 'category filtering on subcategories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user