dashboard next: trending search report

This commit also improves how data is loaded sync and async
This commit is contained in:
Joffrey JAFFEUX
2018-04-19 18:19:21 +02:00
committed by GitHub
parent 108e622a61
commit 0e414d0890
16 changed files with 310 additions and 113 deletions

View File

@ -279,6 +279,37 @@ describe Report do
end
end
describe 'trending search report' do
let(:report) { Report.find('trending_search') }
context "no searches" do
it "returns an empty report" do
expect(report.data).to be_blank
end
end
context "with different searches" do
before do
SearchLog.log(term: 'ruby', search_type: :header, ip_address: '127.0.0.1')
SearchLog.log(term: 'ruby', search_type: :header, ip_address: '127.0.0.1', user_id: Fabricate(:user).id)
SearchLog.log(term: 'ruby', search_type: :header, ip_address: '127.0.0.2')
SearchLog.log(term: 'php', search_type: :header, ip_address: '127.0.0.1')
end
it "returns a report with data" do
expect(report.data).to be_present
expect(report.data[0][0]).to eq "ruby"
expect(report.data[0][1]).to eq 3
expect(report.data[0][2]).to eq 2
expect(report.data[1][0]).to eq "php"
expect(report.data[1][1]).to eq 1
expect(report.data[1][2]).to eq 1
end
end
end
describe 'posts counts' do
it "only counts regular posts" do
post = Fabricate(:post)