FEATURE: Add Top Ignored Users report (#7153)

* FEATURE: Add `Top Ignored Users` report

## Why?

This is part of the [Ability to ignore a user feature](https://meta.discourse.org/t/ability-to-ignore-a-user/110254/8), and also part of [this PR](https://github.com/discourse/discourse/pull/7144).

We want to send a System Message daily when a specific count threshold for an ignored is reached. To make this system message informative, we want to link to a report for the Top Ignored Users too.
This commit is contained in:
Tarek Khalil
2019-03-12 16:01:58 +00:00
committed by GitHub
parent 4a00772c19
commit 28384ba62c
3 changed files with 83 additions and 0 deletions

View File

@@ -1094,6 +1094,35 @@ describe Report do
include_examples "no data"
end
describe "report_top_ignored_users" do
let(:report) { Report.find("top_ignored_users") }
let(:tarek) { Fabricate(:user, username: "tarek") }
let(:john) { Fabricate(:user, username: "john") }
let(:matt) { Fabricate(:user, username: "matt") }
context "with data" do
before do
Fabricate(:ignored_user, user: tarek, ignored_user: john)
Fabricate(:ignored_user, user: tarek, ignored_user: matt)
end
it "works" do
expect(report.data.length).to eq(2)
expect_row_to_be_equal(report.data[0], john)
expect_row_to_be_equal(report.data[1], matt)
end
def expect_row_to_be_equal(row, user)
expect(row[:ignored_user_id]).to eq(user.id)
expect(row[:ignored_username]).to eq(user.username)
expect(row[:ignored_user_avatar_template]).to eq(User.avatar_template(user.username, user.uploaded_avatar_id))
expect(row[:ignores_count]).to eq(1)
end
end
include_examples "no data"
end
describe "consolidated_page_views" do
before do
freeze_time(Time.now.at_midnight)