FIX: Bulk updating category failed when topic title was too short
This commit is contained in:
parent
7290765a62
commit
c358421ca5
|
@ -682,7 +682,7 @@ class Topic < ActiveRecord::Base
|
||||||
old_category = category
|
old_category = category
|
||||||
|
|
||||||
if self.category_id != new_category.id
|
if self.category_id != new_category.id
|
||||||
self.update!(category_id: new_category.id)
|
self.update_attribute(:category_id, new_category.id)
|
||||||
|
|
||||||
if old_category
|
if old_category
|
||||||
Category
|
Category
|
||||||
|
|
|
@ -1181,6 +1181,12 @@ describe Topic do
|
||||||
topic.change_category_to_id(12312312)
|
topic.change_category_to_id(12312312)
|
||||||
expect(topic.category_id).to eq(SiteSetting.uncategorized_category_id)
|
expect(topic.category_id).to eq(SiteSetting.uncategorized_category_id)
|
||||||
end
|
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)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with a previous category' do
|
describe 'with a previous category' do
|
||||||
|
|
Loading…
Reference in New Issue