From c375c9ac1c2a14bcf4e979ba1b8571a66ab3cc86 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 16 Jan 2025 10:47:45 +1100 Subject: [PATCH] Fix user seeding --- db/default/users.rb | 4 ++-- db/seeds.rb | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/default/users.rb b/db/default/users.rb index 2c1851032ee..eb0bc7a91f8 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -40,7 +40,7 @@ def create_admin_user load 'spree/user.rb' - if Spree::User.find_by(email:) + if Spree::User.find_by(email: attributes[:email]) say <<~TEXT WARNING: There is already a user with the email: #{email}, @@ -76,7 +76,7 @@ def read_user_attributes password = ENV.fetch("ADMIN_PASSWORD", "ofn123") email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com") else - Rails.logger.debug 'Create the admin user (press enter for defaults).' + say 'Create the admin user (press enter for defaults).' email = prompt_for_admin_email password = prompt_for_admin_password end diff --git a/db/seeds.rb b/db/seeds.rb index cb055e137bd..3eb57039964 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,30 +8,30 @@ # We need mail_configuration to create a user account, because it sends a confirmation email. MailConfiguration.apply! -Rails.logger.debug "[db:seed] Seeding Roles" +Rails.logger.info "[db:seed] Seeding Roles" Spree::Role.where(name: "admin").first_or_create Spree::Role.where(name: "user").first_or_create -Rails.logger.debug "[db:seed] Seeding Countries" +Rails.logger.info "[db:seed] Seeding Countries" unless Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) require File.join(File.dirname(__FILE__), 'default', 'countries') end country = Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) -Rails.logger.debug { "Default country is #{country}" } +Rails.logger.info { "Default country is #{country}" } -Rails.logger.debug { "[db:seed] Seeding states for #{country.name}" } +Rails.logger.info { "[db:seed] Seeding states for #{country.name}" } states = YAML.load_file "db/default/spree/states.yml" states.each do |state| - Rails.logger.debug { "State: #{state}" } + Rails.logger.info { "State: #{state}" } unless Spree::State.find_by(name: state['name']) Spree::State.create!({ name: state['name'], abbr: state['abbr'], country: }) end end -Rails.logger.debug "[db:seed] Seeding Zones" +Rails.logger.info "[db:seed] Seeding Zones" require File.join(File.dirname(__FILE__), 'default', 'zones') -Rails.logger.debug "[db:seed] Seeding Users" +Rails.logger.info "[db:seed] Seeding Users" require File.join(File.dirname(__FILE__), 'default', 'users') DefaultStockLocation.find_or_create