mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:20:43 +08:00
e219588142
* Introduced fab!, a helper that creates database state for a group It's almost identical to let_it_be, except: 1. It creates a new object for each test by default, 2. You can disable it using PREFABRICATION=0
54 lines
1.8 KiB
Ruby
54 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Jobs::AutoQueueHandler do
|
|
|
|
subject { Jobs::AutoQueueHandler.new.execute({}) }
|
|
|
|
context "old flag" do
|
|
fab!(:old) { Fabricate(:reviewable_flagged_post, created_at: 61.days.ago) }
|
|
fab!(:not_old) { Fabricate(:reviewable_flagged_post, created_at: 59.days.ago) }
|
|
|
|
it "defers the old flag if auto_handle_queued_age is 60" do
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
subject
|
|
expect(not_old.reload).to be_pending
|
|
expect(old.reload).not_to be_pending
|
|
end
|
|
|
|
it "doesn't defer the old flag if auto_handle_queued_age is 0" do
|
|
SiteSetting.auto_handle_queued_age = 0
|
|
subject
|
|
expect(not_old.reload).to be_pending
|
|
expect(old.reload).to be_pending
|
|
end
|
|
end
|
|
|
|
context "reviewables" do
|
|
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) }
|
|
|
|
it "rejects the post when auto_handle_queued_age is 60" do
|
|
SiteSetting.auto_handle_queued_age = 60
|
|
subject
|
|
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)
|
|
end
|
|
|
|
it "leaves reviewables as pending auto_handle_queued_age is 0" do
|
|
SiteSetting.auto_handle_queued_age = 0
|
|
subject
|
|
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)
|
|
end
|
|
end
|
|
|
|
end
|