From ff3a1eae3a40511e5026fad09570c2d3ea166348 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Fri, 7 Jun 2019 14:56:31 +1000 Subject: [PATCH] FIX: ensure consistency should handle cases where a topic trashed Followup to c05b6170 --- app/models/category.rb | 2 +- spec/models/category_spec.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/category.rb b/app/models/category.rb index f2cc2512f2a..53f14e45d28 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -679,7 +679,7 @@ class Category < ActiveRecord::Base SQL DB.query_single(sql).each do |id| - Topic.find(id).destroy! + Topic.with_deleted.find_by(id: id).destroy! end sql = <<~SQL diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 7f175b22e24..18cf7ce280a 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -898,6 +898,9 @@ describe Category do uncategorized.create_category_definition uncategorized.topic.posts.first.destroy! + # make stuff extra broken + uncategorized.topic.trash! + category = Fabricate(:category) category_destroyed = Fabricate(:category) category_trashed = Fabricate(:category)