added tests and enabled queue when new setting is > 0

This commit is contained in:
pmusaraj 2016-09-22 14:51:36 -04:00
parent 5dbb3035d4
commit 0344388924
2 changed files with 26 additions and 0 deletions

View File

@ -115,6 +115,7 @@ class NewPostManager
def self.queue_enabled?
SiteSetting.approve_post_count > 0 ||
SiteSetting.approve_unless_trust_level.to_i > 0 ||
SiteSetting.approve_new_topics_unless_trust_level.to_i > 0 ||
handlers.size > 1
end

View File

@ -115,6 +115,31 @@ describe NewPostManager do
end
end
context 'with a high trust level setting for new topics but post responds to existing topic' do
before do
SiteSetting.approve_new_topics_unless_trust_level = 4
end
it "doesn't return a result action" do
result = NewPostManager.default_handler(manager)
expect(result).to eq(nil)
end
end
end
context "new topic handler" do
let(:manager) { NewPostManager.new(topic.user, raw: 'this is new topic content', title: 'new topic title') }
context 'with a high trust level setting for new topics' do
before do
SiteSetting.approve_new_topics_unless_trust_level = 4
end
it "will return an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
end
end
end
context "extensibility priority" do