From 867c1a5ac9355aadef35d60fd9c7aa4ebd0eda25 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 9 May 2019 14:46:43 +0800 Subject: [PATCH] DEV: Add request spec for creating an uncategorized category. --- spec/requests/posts_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb index 3657507c7b7..e07a238b8c4 100644 --- a/spec/requests/posts_controller_spec.rb +++ b/spec/requests/posts_controller_spec.rb @@ -961,6 +961,25 @@ describe PostsController do expect(topic.meta_data).to eq("xyz" => 'abc') end + it 'can create an uncategorized topic' do + title = 'this is the test title for the topic' + + expect do + post "/posts.json", params: { + raw: 'this is the test content', + title: title, + category: "" + } + + expect(response.status).to eq(200) + end.to change { Topic.count }.by(1) + + topic = Topic.last + + expect(topic.title).to eq(title.capitalize) + expect(topic.category_id).to eq(SiteSetting.uncategorized_category_id) + end + it 'can create a reply to a post' do topic = Fabricate(:private_message_post, user: user).topic post_2 = Fabricate(:private_message_post, user: user, topic: topic)