From 53ef1de4fcdc7ea0f94ae8fe73f9a2b46e376223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 30 Mar 2017 10:41:45 +0200 Subject: Fix production admin fixture to use the new `Users::CreateService` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/production/001_admin.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'db/fixtures') diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index b37dc794015..1c7c89f7bbd 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -12,10 +12,12 @@ else user_args[:password] = ENV['GITLAB_ROOT_PASSWORD'] end -user = User.new(user_args) -user.skip_confirmation! +# Only admins can create other admin users in Users::CreateService so to solve +# the chicken-and-egg problem, we pass a non-persisted admin user to the service. +transient_admin = User.new(admin: true) +user = Users::CreateService.new(transient_admin, user_args.merge!(skip_confirmation: true)).execute -if user.save +if user.persisted? puts "Administrator account created:".color(:green) puts puts "login: root".color(:green) -- cgit v1.2.3