FIX: ensure discobot always has a primary email

This commit is contained in:
Régis Hanol 2017-11-23 16:54:40 +01:00
parent 616a0dae4e
commit a38391a6bc
1 changed files with 12 additions and 4 deletions

View File

@ -1,15 +1,16 @@
discobot_username = 'discobot'
user = User.find_by(id: -2)
if !user
suggested_username = UserNameSuggester.suggest(discobot_username)
def seed_primary_email
UserEmail.seed do |ue|
ue.id = -2
ue.email = "discobot_email"
ue.primary = true
ue.user_id = -2
end
end
unless user = User.find_by(id: -2)
suggested_username = UserNameSuggester.suggest(discobot_username)
User.seed do |u|
u.id = -2
@ -37,6 +38,13 @@ if !user
end
bot = User.find(-2)
# ensure discobot has a primary email
unless bot.primary_email
seed_primary_email
bot.reload
end
bot.update!(admin: true, moderator: false)
bot.user_option.update!(