Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Pending queued posts are included even if they don't pass the minimum priority threshold (#8925)

Roman Rizzi3413ec0a5ce3
diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index c12bfae39ff..78d4b98e650 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -472,10 +472,15 @@ class Reviewable < ActiveRecord::Base
result = result.where(type: type) if type
result = result.where(category_id: category_id) if category_id
result = result.where(topic_id: topic_id) if topic_id
- result = result.where("score >= ?", min_score) if min_score > 0
result = result.where("created_at >= ?", from_date) if from_date
result = result.where("created_at <= ?", to_date) if to_date
+ if min_score > 0 && status == :pending && type.nil?
+ result = result.where("score >= ? OR type = ?", min_score, ReviewableQueuedPost.name)
+ elsif min_score > 0
+ result = result.where("score >= ?", min_score)
+ end
+
if !custom_filters.empty?
result = custom_filters.reduce(result) do |memo, filter|
key = filter.first
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index 615f6e581d8..ff2e31fd108 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -175,6 +175,26 @@ RSpec.describe Reviewable, type: :model do
expect(list[0].id).to eq(r0.id)
expect(list[1].id).to eq(r1.id)
end
+
+ describe "Including pending queued posts even if they don't pass the minimum priority threshold" do
+ before do
+ SiteSetting.reviewable_default_visibility = :high
+ Reviewable.set_priorities(high: 10)
+ @queued_post = Fabricate(:reviewable_queued_post, score: 0, target: post)
+ end
+
+ it 'includes queued posts when searching for pending reviewables' do
+ expect(Reviewable.list_for(user)).to contain_exactly(@queued_post)
+ end
+
+ it 'excludes pending queued posts when applying a different status filter' do
+ expect(Reviewable.list_for(user, status: :deleted)).to be_empty
+ end
+
+ it 'excludes pending queued posts when applying a different type filter' do
+ expect(Reviewable.list_for(user, type: ReviewableFlaggedPost.name)).to be_empty
+ end
+ end
end
end
@@ -203,7 +223,6 @@ RSpec.describe Reviewable, type: :model do
expect(Reviewable.list_for(moderator)).to include(reviewable)
end
end
-
end
it "valid_types returns the appropriate types" do