Class: Spree::Seeds::AdminUser

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree/seeds/admin_user.rb

Instance Method Summary collapse

Methods included from Spree::ServiceModule::Base

prepended

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/spree/seeds/admin_user.rb', line 6

def call
  if Spree.admin_user_class.present? && Spree.admin_user_class.count.zero?
    user = Spree.admin_user_class.create!(
      email: ENV.fetch('ADMIN_EMAIL', '[email protected]'),
      password: ENV.fetch('ADMIN_PASSWORD', 'spree123'),
      password_confirmation: ENV.fetch('ADMIN_PASSWORD', 'spree123'),
      first_name: ENV.fetch('ADMIN_FIRST_NAME', 'Spree'),
      last_name: ENV.fetch('ADMIN_LAST_NAME', 'Admin')
    )
    user.save!

    Spree::Store.all.each do |store|
      store.add_user(user)
    end
  end
end