docbrown/app/services/users/create_mascot_account.rb
Michael Kohl f2f5e911cf
Add Settings::Mascot (#13451)
* Add Settings::Mascot

* Add DUS

* Update usage

* Fix e2e test and controller

* Fix specs

* Fix remaining spec
2021-04-26 11:39:19 +07:00

29 lines
688 B
Ruby

module Users
class CreateMascotAccount
MASCOT_PARAMS = {
email: "mascot@forem.com",
username: "mascot",
name: "Mascot",
profile_image: Settings::Mascot.image_url,
confirmed_at: Time.current,
registered_at: Time.current,
password: SecureRandom.hex
}.freeze
def self.call
new.call
end
def call
raise "Mascot already set" if Settings::Mascot.mascot_user_id
mascot = User.create!(mascot_params)
Settings::Mascot.mascot_user_id = mascot.id
end
def mascot_params
# Set the password_confirmation
MASCOT_PARAMS.merge(password_confirmation: MASCOT_PARAMS[:password])
end
end
end