diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb index 92baa71cce4..c99abea3542 100644 --- a/lib/new_post_manager.rb +++ b/lib/new_post_manager.rb @@ -188,6 +188,7 @@ class NewPostManager reviewable_by_moderator: true ) reviewable.payload['title'] = @args[:title] if @args[:title].present? + reviewable.category_id = args[:category] if args[:category].present? create_options = reviewable.create_options diff --git a/spec/components/new_post_manager_spec.rb b/spec/components/new_post_manager_spec.rb index c1a3efcb418..bc35f00730c 100644 --- a/spec/components/new_post_manager_spec.rb +++ b/spec/components/new_post_manager_spec.rb @@ -133,6 +133,27 @@ describe NewPostManager do end end + context "with uncategorized disabled, and approval" do + before do + SiteSetting.allow_uncategorized_topics = false + SiteSetting.approve_unless_trust_level = 4 + end + + it "will return an enqueue result" do + npm = NewPostManager.new( + Fabricate(:user), + title: 'this is a new topic title', + raw: "this is the raw content", + category: Fabricate(:category).id + ) + + result = NewPostManager.default_handler(npm) + expect(NewPostManager.queue_enabled?).to eq(true) + expect(result.action).to eq(:enqueued) + expect(result.errors).to be_blank + end + end + context 'with staged moderation setting enabled' do before do SiteSetting.approve_unless_staged = true