2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Jobs::AutoQueueHandler do
|
2017-09-14 12:00:37 -04:00
|
|
|
subject { Jobs::AutoQueueHandler.new.execute({}) }
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
describe "old flagged post" do
|
2019-05-27 17:22:39 -04:00
|
|
|
fab!(:spam_result) do
|
|
|
|
PostActionCreator.new(
|
|
|
|
Fabricate(:user),
|
|
|
|
Fabricate(:post),
|
|
|
|
PostActionType.types[:spam],
|
|
|
|
message: 'this is the initial message'
|
|
|
|
).perform
|
|
|
|
end
|
|
|
|
|
|
|
|
fab!(:post_action) { spam_result.post_action }
|
|
|
|
fab!(:old) {
|
|
|
|
spam_result.reviewable.update_column(:created_at, 61.days.ago)
|
|
|
|
spam_result.reviewable
|
|
|
|
}
|
|
|
|
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:not_old) { Fabricate(:reviewable_flagged_post, created_at: 59.days.ago) }
|
2017-09-14 12:00:37 -04:00
|
|
|
|
|
|
|
it "defers the old flag if auto_handle_queued_age is 60" do
|
|
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
|
|
subject
|
2019-01-03 12:03:01 -05:00
|
|
|
expect(not_old.reload).to be_pending
|
|
|
|
expect(old.reload).not_to be_pending
|
2019-05-27 17:22:39 -04:00
|
|
|
expect(post_action.related_post.topic.posts_count).to eq(1)
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't defer the old flag if auto_handle_queued_age is 0" do
|
|
|
|
SiteSetting.auto_handle_queued_age = 0
|
|
|
|
subject
|
2019-01-03 12:03:01 -05:00
|
|
|
expect(not_old.reload).to be_pending
|
|
|
|
expect(old.reload).to be_pending
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-27 12:14:14 -04:00
|
|
|
describe "reviewables" do
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:new_post) { Fabricate(:reviewable_queued_post, created_at: 59.days.ago) }
|
|
|
|
fab!(:old_post) { Fabricate(:reviewable_queued_post, created_at: 61.days.ago) }
|
|
|
|
fab!(:new_user) { Fabricate(:reviewable, created_at: 10.days.ago) }
|
|
|
|
fab!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) }
|
2017-09-14 12:00:37 -04:00
|
|
|
|
|
|
|
it "rejects the post when auto_handle_queued_age is 60" do
|
|
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
|
|
subject
|
2019-01-03 12:03:01 -05:00
|
|
|
expect(new_post.reload.pending?).to eq(true)
|
|
|
|
expect(old_post.reload.rejected?).to eq(true)
|
|
|
|
expect(new_user.reload.pending?).to eq(true)
|
|
|
|
expect(old_user.reload.rejected?).to eq(true)
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
it "leaves reviewables as pending auto_handle_queued_age is 0" do
|
2017-09-14 12:00:37 -04:00
|
|
|
SiteSetting.auto_handle_queued_age = 0
|
|
|
|
subject
|
2019-01-03 12:03:01 -05:00
|
|
|
expect(new_post.reload.pending?).to eq(true)
|
|
|
|
expect(new_user.reload.pending?).to eq(true)
|
|
|
|
expect(old_post.reload.pending?).to eq(true)
|
|
|
|
expect(old_user.reload.pending?).to eq(true)
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|