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.rbindex c12bfae39ff..78d4b98e650 100644--- a/app/models/reviewable.rb+++ b/app/models/reviewable.rb@@ -472,10 +472,15 @@ class Reviewable < ActiveRecord::Baseresult = result.where(type: type) if typeresult = result.where(category_id: category_id) if category_idresult = result.where(topic_id: topic_id) if topic_id- result = result.where("score >= ?", min_score) if min_score > 0result = result.where("created_at >= ?", from_date) if from_dateresult = 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.firstdiff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rbindex 615f6e581d8..ff2e31fd108 100644--- a/spec/models/reviewable_spec.rb+++ b/spec/models/reviewable_spec.rb@@ -175,6 +175,26 @@ RSpec.describe Reviewable, type: :model doexpect(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+ endendend@@ -203,7 +223,6 @@ RSpec.describe Reviewable, type: :model doexpect(Reviewable.list_for(moderator)).to include(reviewable)endend-endit "valid_types returns the appropriate types" do