From 03443889241e3b9ee8846c91199e486d3da58aa0 Mon Sep 17 00:00:00 2001 From: pmusaraj Date: Thu, 22 Sep 2016 14:51:36 -0400 Subject: [PATCH] added tests and enabled queue when new setting is > 0 --- lib/new_post_manager.rb | 1 + spec/components/new_post_manager_spec.rb | 25 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb index 026f7875737..27aebae6639 100644 --- a/lib/new_post_manager.rb +++ b/lib/new_post_manager.rb @@ -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 diff --git a/spec/components/new_post_manager_spec.rb b/spec/components/new_post_manager_spec.rb index fb116adbf77..3b38304d177 100644 --- a/spec/components/new_post_manager_spec.rb +++ b/spec/components/new_post_manager_spec.rb @@ -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