Module: Virtuatable::Specs::Factories::Accounts
- Extended by:
- ActiveSupport::Concern
- Included in:
- Builders::Tests
- Defined in:
- lib/virtuatable/specs/factories/accounts.rb
Overview
This module creates the factories concerning accounts, with or without rights, and with random values for each field.
Instance Method Summary collapse
-
#load_accounts_factory! ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#load_accounts_factory! ⇒ Object
rubocop:disable Metrics/MethodLength
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/virtuatable/specs/factories/accounts.rb', line 17 def load_accounts_factory! # This avoids multiple re-declarations by setting a flag. return if self.class.class_variable_defined?(:@@accounts_declared) FactoryBot.define do factory :vt_empty_account, class: Arkaan::Account do # Creates a random account with no particular right. This # is useful to see when a user is NOT authorized to access # a resource. Add groups to access resources. factory :random_account do username do Faker::Alphanumeric.unique.alphanumeric( number: 16, min_alpha: 16 ) end password { 'super_secure_pwd' } password_confirmation { 'super_secure_pwd' } email { Faker::Internet.unique.safe_email } # This creates an administrator as "a user with access to # all the routes in a group". This is NOT a superuser. factory :random_administrator do groups { [association(:random_admin_group)] } end end end end # rubocop:disable Style/ClassVars @@accounts_declared = true # rubocop:enable Style/ClassVars end |