A platform for community discussion. Free, open, simple.
FIX: Bulk updating category failed when topic title was too short
Gerhard Schlagerc358421ca5f2
diff --git a/app/models/topic.rb b/app/models/topic.rbindex c54ab04f77c..7a7c2ae0af7 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -682,7 +682,7 @@ class Topic < ActiveRecord::Baseold_category = categoryif self.category_id != new_category.id- self.update!(category_id: new_category.id)+ self.update_attribute(:category_id, new_category.id)if old_categoryCategorydiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 9e6b5afce5c..df1b61225dc 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1181,6 +1181,12 @@ describe Topic dotopic.change_category_to_id(12312312)expect(topic.category_id).to eq(SiteSetting.uncategorized_category_id)end++ it "changes the category even when the topic title is invalid" do+ SiteSetting.min_topic_title_length = 5+ topic.update_column(:title, "xyz")+ expect { topic.change_category_to_id(category.id) }.to change { topic.category_id }.to(category.id)+ endenddescribe 'with a previous category' do