Class: TinyGate::TestHelper::User

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_gate/test_helper/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, email, password, first_name = 'First', last_name = 'Last') ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
13
14
15
# File 'lib/tiny_gate/test_helper/user.rb', line 6

def initialize(id, email, password, first_name = 'First', last_name = 'Last')
  @id          = id
  @email       = email
  @password    = password
  @first_name  = first_name
  @last_name   = last_name
  @token       = SecureRandom.hex
  @permissions = Set.new
  @current_organization_id = nil
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def last_name
  @last_name
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def password
  @password
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/tiny_gate/test_helper/user.rb', line 4

def token
  @token
end

Instance Method Details

#add_permission(permission_id, role_id, role_name, organization_id, organization_name = nil, app_id = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/tiny_gate/test_helper/user.rb', line 21

def add_permission(permission_id, role_id, role_name, organization_id, organization_name = nil, app_id = nil)
  @permissions << OpenStruct.new(
    id:                permission_id,
    role_id:           role_id,
    role_name:         role_name,
    organization_id:   organization_id,
    organization_name: organization_name,
    app_id:            app_id
  )
end

#dataObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tiny_gate/test_helper/user.rb', line 32

def data
  {
    id:                 id,
    email:              email,
    token:              token,
    first_name:         first_name,
    last_name:          last_name,
    current_permission: current_permission,
    active_permissions: active_permissions
  }
end

#sign_in(organization_id = nil) ⇒ Object



17
18
19
# File 'lib/tiny_gate/test_helper/user.rb', line 17

def (organization_id = nil)
  @current_organization_id = organization_id
end