mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
When creating a topic, don't select a category by default when allow_uncategorized_topics is false. Also, added category validation on the server to enforce allow_uncategorized_topics.
This commit is contained in:
@@ -637,7 +637,7 @@ describe TopicsController do
|
||||
end
|
||||
|
||||
it 'triggers a change of category' do
|
||||
Topic.any_instance.expects(:change_category).with('incredible')
|
||||
Topic.any_instance.expects(:change_category).with('incredible').returns(true)
|
||||
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: 'incredible'
|
||||
end
|
||||
|
||||
@@ -646,6 +646,24 @@ describe TopicsController do
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "returns errors with invalid categories" do
|
||||
Topic.any_instance.expects(:change_category).returns(false)
|
||||
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: ''
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
context "allow_uncategorized_topics is false" do
|
||||
before do
|
||||
SiteSetting.stubs(:allow_uncategorized_topics).returns(false)
|
||||
end
|
||||
|
||||
it "can add a category to an uncategorized topic" do
|
||||
Topic.any_instance.expects(:change_category).with('incredible').returns(true)
|
||||
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: 'incredible'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user