mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
Seed categories in transactions
This commit is contained in:
@ -5,6 +5,7 @@ unless Rails.env.test?
|
||||
# The category for users with trust level 3 has been created.
|
||||
# Add permissions and a description to it.
|
||||
|
||||
Category.transaction do
|
||||
lounge.group_names = ['trust_level_3']
|
||||
unless lounge.save
|
||||
puts lounge.errors.full_messages
|
||||
@ -37,4 +38,5 @@ unless Rails.env.test?
|
||||
Category.exec_sql "UPDATE categories SET topic_count = 0 WHERE id = #{lounge.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,7 @@ unless Rails.env.test?
|
||||
meta = Category.where(id: SiteSetting.meta_category_id).first
|
||||
if meta && !meta.topic_id
|
||||
|
||||
Category.transaction do
|
||||
creator = PostCreator.new(Discourse.system_user,
|
||||
raw: I18n.t('meta_category_description'),
|
||||
title: I18n.t('category.topic_prefix', category: meta.name),
|
||||
@ -26,4 +27,5 @@ unless Rails.env.test?
|
||||
# Reset topic count because we don't count the description topic
|
||||
Category.exec_sql "UPDATE categories SET topic_count = 0 WHERE id = #{meta.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,7 @@ unless Rails.env.test?
|
||||
|
||||
# Add permissions and a description to the Staff category.
|
||||
|
||||
Category.transaction do
|
||||
staff.group_names = ['staff']
|
||||
unless staff.save
|
||||
puts staff.errors.full_messages
|
||||
@ -35,4 +36,5 @@ unless Rails.env.test?
|
||||
Category.exec_sql "UPDATE categories SET topic_count = 0 WHERE id = #{staff.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user