mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Import sub-sub-categories (#8810)
This should make the importer more resilient to incomplete or damaged backups. It will disable some validations and attempt to automatically repair category permissions before importing.
This commit is contained in:
@ -33,17 +33,43 @@ describe ImportExport::Importer do
|
||||
.and change { User.count }.by(2)
|
||||
end
|
||||
|
||||
it 'categories and groups' do
|
||||
data = import_data.dup
|
||||
data[:topics] = nil
|
||||
data[:users] = nil
|
||||
context 'categories and groups' do
|
||||
it 'works' do
|
||||
data = import_data.dup
|
||||
data[:topics] = nil
|
||||
data[:users] = nil
|
||||
|
||||
expect {
|
||||
import(data)
|
||||
}.to change { Category.count }.by(6)
|
||||
.and change { Group.count }.by(2)
|
||||
.and change { Topic.count }.by(6)
|
||||
.and change { User.count }.by(0)
|
||||
expect {
|
||||
import(data)
|
||||
}.to change { Category.count }.by(6)
|
||||
.and change { Group.count }.by(2)
|
||||
.and change { Topic.count }.by(6)
|
||||
.and change { User.count }.by(0)
|
||||
end
|
||||
|
||||
it 'works with sub-sub-categories' do
|
||||
data = import_data.dup
|
||||
|
||||
# 11 -> 10 -> 15
|
||||
data[:categories].find { |c| c[:id] == 10 }[:parent_category_id] = 11
|
||||
data[:categories].find { |c| c[:id] == 15 }[:parent_category_id] = 10
|
||||
|
||||
expect { import(data) }
|
||||
.to change { Category.count }.by(6)
|
||||
.and change { SiteSetting.max_category_nesting }.from(2).to(3)
|
||||
end
|
||||
|
||||
it 'fixes permissions' do
|
||||
data = import_data.dup
|
||||
data[:categories].find { |c| c[:id] == 10 }[:permissions_params] = { custom_group: 1 }
|
||||
data[:categories].find { |c| c[:id] == 15 }[:permissions_params] = { staff: 1 }
|
||||
|
||||
permissions = data[:categories].find { |c| c[:id] == 10 }[:permissions_params]
|
||||
|
||||
expect { import(data) }
|
||||
.to change { Category.count }.by(6)
|
||||
.and change { permissions[:staff] }.from(nil).to(1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'categories, groups and users' do
|
||||
|
Reference in New Issue
Block a user