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:
Neil Lalonde
2013-10-08 14:40:31 -04:00
parent 32af23884e
commit bccb37b6f3
9 changed files with 92 additions and 20 deletions

View File

@@ -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