mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:42:46 +08:00
FIX: corrects typo and adds a spec for likes report (#6439)
* FIX: corrects typo and adds a spec for likes report * save!
This commit is contained in:
parent
3b1e13e4ab
commit
a515ba8612
|
@ -143,7 +143,7 @@ class PostAction < ActiveRecord::Base
|
|||
result = unscoped.where(post_action_type_id: post_action_type)
|
||||
result = result.where('post_actions.created_at >= ?', opts[:start_date] || (opts[:since_days_ago] || 30).days.ago)
|
||||
result = result.where('post_actions.created_at <= ?', opts[:end_date]) if opts[:end_date]
|
||||
result = result.joins(post: :topic).merge(Topic.in_category_and_categories(opts[:category_id])) if opts[:category_id]
|
||||
result = result.joins(post: :topic).merge(Topic.in_category_and_subcategories(opts[:category_id])) if opts[:category_id]
|
||||
result.group('date(post_actions.created_at)')
|
||||
.order('date(post_actions.created_at)')
|
||||
.count
|
||||
|
|
|
@ -890,4 +890,40 @@ describe Report do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'likes' do
|
||||
let(:report) { Report.find('likes') }
|
||||
|
||||
include_examples 'no data'
|
||||
|
||||
context 'with data' do
|
||||
include_examples 'with data x/y'
|
||||
|
||||
before(:each) do
|
||||
topic = Fabricate(:topic, category_id: 2)
|
||||
post = Fabricate(:post, topic: topic)
|
||||
PostAction.act(Fabricate(:user), post, PostActionType.types[:like])
|
||||
|
||||
topic = Fabricate(:topic, category_id: 4)
|
||||
post = Fabricate(:post, topic: topic)
|
||||
PostAction.act(Fabricate(:user), post, PostActionType.types[:like])
|
||||
PostAction.act(Fabricate(:user), post, PostActionType.types[:like])
|
||||
PostAction.act(Fabricate(:user), post, PostActionType.types[:like]).tap do |pa|
|
||||
pa.created_at = 45.days.ago
|
||||
end.save!
|
||||
end
|
||||
|
||||
context "with category filtering" do
|
||||
let(:report) { Report.find('likes', category_id: 2) }
|
||||
|
||||
include_examples 'category filtering'
|
||||
|
||||
context "on subcategories" do
|
||||
let(:report) { Report.find('likes', category_id: 3) }
|
||||
|
||||
include_examples 'category filtering on subcategories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user