Module: Virtuatable::Specs::Factories::Sessions

Extended by:
ActiveSupport::Concern
Included in:
Builders::Tests
Defined in:
lib/virtuatable/specs/factories/sessions.rb

Overview

This module creates the factories concerning accounts, with or without rights, and with random values for each field.

Author:

Instance Method Summary collapse

Instance Method Details

#load_sessions_factory!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/virtuatable/specs/factories/sessions.rb', line 16

def load_sessions_factory!
  # This avoids multiple re-declarations by setting a flag.
  return if self.class.class_variable_defined?(:@@sessions_declared)

  FactoryBot.define do
    factory :vt_empty_session, class: Arkaan::Authentication::Session 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_session do
        session_id { BSON::ObjectId.new }
      end
    end
  end

  # rubocop:disable Style/ClassVars
  @@sessions_declared = true
  # rubocop:enable Style/ClassVars
end