diff --git a/app/models/topic.rb b/app/models/topic.rb index deda3d2256d..f0933b0d4c4 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -540,6 +540,7 @@ class Topic < ActiveRecord::Base def change_category_to_id(category_id) return false if private_message? + return false if category.try(:is_support) new_category_id = category_id.to_i # if the category name is blank, reset the attribute diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb index feaf5603c63..09cd717b93e 100644 --- a/spec/controllers/topics_controller_spec.rb +++ b/spec/controllers/topics_controller_spec.rb @@ -898,6 +898,18 @@ describe TopicsController do end end + context 'when topic is in support category' do + let(:another_category) { Fabricate(:category) } + + it "cannot change the category of a topic that is in a support category" do + @topic.category = Fabricate(:category, is_support: true) + @topic.save! + xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category_id: another_category.id + expect(response).not_to be_success + end + + end + context "allow_uncategorized_topics is false" do before do SiteSetting.stubs(:allow_uncategorized_topics).returns(false)