FIX: There was an error renaming the Uncategorized topic

This commit is contained in:
Robin Ward 2014-07-25 16:36:16 -04:00
parent 625d74dd10
commit 6ba5f715f3
2 changed files with 5 additions and 0 deletions

View file

@ -337,6 +337,7 @@ SQL
# an exact match
def rename_category_definition
old_name = changed_attributes["name"]
return unless topic.present?
if topic.title == I18n.t("category.topic_prefix", category: old_name)
topic.update_column(:title, I18n.t("category.topic_prefix", category: name))
end

View file

@ -226,6 +226,10 @@ describe Category do
@topic.title.should =~ /Troutfishing/
end
it "doesn't raise an error if there is no definition topic to rename (uncategorized)" do
-> { @category.update_attributes(name: 'Troutfishing', topic_id: nil) }.should_not raise_error
end
it "should not set its description topic to auto-close" do
category = Fabricate(:category, name: 'Closing Topics', auto_close_hours: 1)
category.topic.auto_close_at.should be_nil