Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add request spec for creating an uncategorized category.

Guo Xiang Tan867c1a5ac935
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)