Sha256: 3105f54c98e8dfdf1676a5b30d34a104b80ef06263f8d889d0dd2e3ae4c27993
Contents?: true
Size: 1020 Bytes
Versions: 2
Compression:
Stored size: 1020 Bytes
Contents
# Routine for creating an account, only for use when stubbing and # not on production. module OpenStax module Accounts module Dev class CreateAccount lev_routine protected def exec(inputs={}) fatal_error(:code => :cannot_create_account_in_production) if Rails.env.production? fatal_error(:code => :can_only_create_account_when_stubbing) if !OpenStax::Accounts.configuration.enable_stubbing? username = inputs[:username] while username.nil? || Account.where(username: username).exists? do username = SecureRandom.hex(3).to_s end account = OpenStax::Accounts::Account.new account.openstax_uid = -SecureRandom.hex.to_i(16) account.access_token = SecureRandom.hex.to_s account.username = username account.save transfer_errors_from(account, {type: :verbatim}, true) outputs[:account] = account end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstax_accounts-3.1.1 | app/routines/openstax/accounts/dev/create_account.rb |
openstax_accounts-3.1.0 | app/routines/openstax/accounts/dev/create_account.rb |