mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 06:56:01 +08:00
FIX: Recalculate scores only when approving or transitioning to pending. (#13009)
Recalculating a ReviewableFlaggedPost's score after rejecting or ignoring it sets the score as 0, which means that we can't find them after reviewing. They don't surpass the minimum priority threshold and are hidden. Additionally, we only want to use agreed flags when calculating the different priority thresholds.
This commit is contained in:
@ -305,6 +305,23 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'recalculating the reviewable score' do
|
||||
let(:expected_score) { 8 }
|
||||
let(:reviewable) { Fabricate(:reviewable_flagged_post, score: expected_score) }
|
||||
|
||||
it "doesn't recalculate the score after ignore" do
|
||||
reviewable.perform(moderator, :ignore)
|
||||
|
||||
expect(reviewable.score).to eq(expected_score)
|
||||
end
|
||||
|
||||
it "doesn't recalculate the score after disagree" do
|
||||
reviewable.perform(moderator, :disagree)
|
||||
|
||||
expect(reviewable.score).to eq(expected_score)
|
||||
end
|
||||
end
|
||||
|
||||
def assert_pm_creation_enqueued(user_id, pm_type)
|
||||
expect(Jobs::SendSystemMessage.jobs.length).to eq(1)
|
||||
job = Jobs::SendSystemMessage.jobs[0]
|
||||
|
@ -35,7 +35,7 @@ RSpec.describe ReviewableScore, type: :model do
|
||||
expect(rs.reload).to be_disagreed
|
||||
expect(rs.reviewed_by).to eq(moderator)
|
||||
expect(rs.reviewed_at).to be_present
|
||||
expect(reviewable.score).to eq(0.0)
|
||||
expect(reviewable.score).to eq(4.0)
|
||||
end
|
||||
|
||||
it "increases the score by the post action type's score bonus" do
|
||||
|
Reference in New Issue
Block a user