Class: Hyrax::TestDataSeeders::UserSeeder

Inherits:
Object
  • Object
show all
Defined in:
app/utils/hyrax/test_data_seeders/user_seeder.rb

Overview

This class was created for use in rake tasks and db/seeds.rb. It generates users that can be used in release testing. This data can also be helpful for local development testing.

Adding users is non-destructive. If a user with the email already exists, they will not be replaced.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



12
13
14
# File 'app/utils/hyrax/test_data_seeders/user_seeder.rb', line 12

def logger
  @logger
end

Class Method Details

.generate_seeds(logger: Logger.new(STDOUT), allow_seeding_in_production: false) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'app/utils/hyrax/test_data_seeders/user_seeder.rb', line 14

def generate_seeds(logger: Logger.new(STDOUT), allow_seeding_in_production: false)
  raise("TestDataSeeders are not for use in production!") if Rails.env.production? && !allow_seeding_in_production
  @logger = logger

  logger.info("Adding users...")

  add_user('[email protected]', 'admin_password', admin_role)
  add_user('[email protected]', 'password')
  add_user('[email protected]', 'password')
end