mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:53:44 +08:00
FIX: Only seed general category on new sites (#18130)
* FIX: Only seed general category on new sites
If the site already has human users (users with an id > 0) don't seed
the categories.
Follow up to: a6ad74c759
* use human_users scope
This commit is contained in:
parent
b58d168f05
commit
00539307e1
|
@ -128,6 +128,8 @@ module SeedData
|
|||
end
|
||||
|
||||
def should_create_category?(category_id, force_existence)
|
||||
return false if User.human_users.any?
|
||||
|
||||
if category_id > 0
|
||||
force_existence ? !Category.exists?(category_id) : false
|
||||
else
|
||||
|
|
|
@ -93,6 +93,22 @@ RSpec.describe SeedData::Categories do
|
|||
end
|
||||
end
|
||||
|
||||
it "does not seed the general category for non-new sites" do
|
||||
Fabricate(:user) # If the site has human users don't seed
|
||||
|
||||
expect { create_category("general_category_id") }
|
||||
.to not_change { Category.count }
|
||||
.and not_change { Topic.count }
|
||||
end
|
||||
|
||||
it "seeds the general category for new sites" do
|
||||
expect { create_category("general_category_id") }
|
||||
.to change { Category.count }
|
||||
.and change { Topic.count }
|
||||
|
||||
expect(Category.last.name).to eq("General")
|
||||
end
|
||||
|
||||
it "does not override permissions of existing category when not forced" do
|
||||
create_category("lounge_category_id")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user