2017-09-15 00:00:37 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Jobs::AutoQueueHandler do
|
|
|
|
|
|
|
|
subject { Jobs::AutoQueueHandler.new.execute({}) }
|
|
|
|
|
|
|
|
context "old flag" do
|
2019-01-04 01:03:01 +08:00
|
|
|
let!(:old) { Fabricate(:reviewable_flagged_post, created_at: 61.days.ago) }
|
|
|
|
let!(:not_old) { Fabricate(:reviewable_flagged_post, created_at: 59.days.ago) }
|
2017-09-15 00:00:37 +08:00
|
|
|
|
|
|
|
it "defers the old flag if auto_handle_queued_age is 60" do
|
|
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
|
|
subject
|
2019-01-04 01:03:01 +08:00
|
|
|
expect(not_old.reload).to be_pending
|
|
|
|
expect(old.reload).not_to be_pending
|
2017-09-15 00:00:37 +08: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-04 01:03:01 +08:00
|
|
|
expect(not_old.reload).to be_pending
|
|
|
|
expect(old.reload).to be_pending
|
2017-09-15 00:00:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
context "reviewables" do
|
|
|
|
let!(:new_post) { Fabricate(:reviewable_queued_post, created_at: 59.days.ago) }
|
|
|
|
let!(:old_post) { Fabricate(:reviewable_queued_post, created_at: 61.days.ago) }
|
|
|
|
let!(:new_user) { Fabricate(:reviewable, created_at: 10.days.ago) }
|
|
|
|
let!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) }
|
2017-09-15 00:00:37 +08:00
|
|
|
|
|
|
|
it "rejects the post when auto_handle_queued_age is 60" do
|
|
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
|
|
subject
|
2019-01-04 01:03:01 +08: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-15 00:00:37 +08:00
|
|
|
end
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
it "leaves reviewables as pending auto_handle_queued_age is 0" do
|
2017-09-15 00:00:37 +08:00
|
|
|
SiteSetting.auto_handle_queued_age = 0
|
|
|
|
subject
|
2019-01-04 01:03:01 +08: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-15 00:00:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|