mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: Handle deleted categories in post export (#10567)
Fixes a crash when exporting my own archive on Meta.
This commit is contained in:
parent
594d919d22
commit
a1dd761bd9
@ -207,7 +207,8 @@ module Jobs
|
||||
|
||||
def piped_category_name(category_id)
|
||||
return "-" unless category_id
|
||||
category = Category.find(category_id)
|
||||
category = Category.find_by(id: category_id)
|
||||
return "#{category_id}" unless category
|
||||
categories = [category.name]
|
||||
while category.parent_category_id && category = category.parent_category
|
||||
categories << category.name
|
||||
|
@ -130,6 +130,18 @@ describe Jobs::ExportUserArchive do
|
||||
expect(post2['reply_count']).to eq(0)
|
||||
end
|
||||
|
||||
it 'can export a post from a deleted category' do
|
||||
cat2 = Fabricate(:category)
|
||||
topic2 = Fabricate(:topic, category: cat2, user: user)
|
||||
post2 = Fabricate(:post, topic: topic2, user: user)
|
||||
|
||||
cat2_id = cat2.id
|
||||
cat2.destroy!
|
||||
|
||||
_, csv_out = make_component_csv
|
||||
expect(csv_out).to match cat2_id.to_s
|
||||
puts csv_out
|
||||
end
|
||||
end
|
||||
|
||||
context 'user_archive_profile' do
|
||||
|
Loading…
Reference in New Issue
Block a user