Class: UserObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, DateFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ UserObject

Returns a new instance of UserObject.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sambal-cle/data_objects/user.rb', line 13

def initialize(browser, opts={})
  @browser = browser
  defaults = {
      :id=>random_alphanums,
      :first_name=>random_alphanums,
      :last_name=>random_alphanums,
      :email=>random_email,
      :type=>"Student",
      :password=>random_alphanums,
  }
  options = defaults.merge(opts)

  set_options(options)
  @full_name="#{@first_name} #{last_name}"
  @long_name="#{@first_name} #{last_name} (#{@id})"
  @ln_fn_id="#{@last_name}, #{@first_name} (#{@id})"
end

Instance Attribute Details

#created_byObject

Returns the value of attribute created_by.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def created_by
  @created_by
end

#creation_dateObject

Returns the value of attribute creation_date.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def creation_date
  @creation_date
end

#emailObject

Returns the value of attribute email.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def first_name
  @first_name
end

#full_nameObject

Returns the value of attribute full_name.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def full_name
  @full_name
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def id
  @id
end

#internal_idObject

Returns the value of attribute internal_id.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def internal_id
  @internal_id
end

#last_nameObject

Returns the value of attribute last_name.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def last_name
  @last_name
end

#ln_fn_idObject

Returns the value of attribute ln_fn_id.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def ln_fn_id
  @ln_fn_id
end

#long_nameObject

Returns the value of attribute long_name.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def long_name
  @long_name
end

#modified_byObject

Returns the value of attribute modified_by.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def modified_by
  @modified_by
end

#modified_dateObject

Returns the value of attribute modified_date.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def modified_date
  @modified_date
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def password
  @password
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/sambal-cle/data_objects/user.rb', line 9

def type
  @type
end

Instance Method Details

#createObject



31
32
33
# File 'lib/sambal-cle/data_objects/user.rb', line 31

def create
  # TODO
end

#deleteObject



43
44
45
# File 'lib/sambal-cle/data_objects/user.rb', line 43

def delete
  # TODO
end

#edit(opts = {}) ⇒ Object



35
36
37
# File 'lib/sambal-cle/data_objects/user.rb', line 35

def edit opts={}
  # TODO
end

#exist?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/sambal-cle/data_objects/user.rb', line 47

def exist?
  # TODO
end

#log_inObject Also known as: login



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/sambal-cle/data_objects/user.rb', line 51

def 
  if logged_in?
    # do nothing
  else # see if we're on the login screen
    if @browser.frame(:id, "ifrm").text_field(:id, "eid").present?
      userlogin
    else # Log the current user out, then log in
      log_out
      userlogin
    end
  end
end

#log_outObject



74
75
76
# File 'lib/sambal-cle/data_objects/user.rb', line 74

def log_out
  @browser.link(:text=>"Logout").click
end

#logged_in?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
71
72
# File 'lib/sambal-cle/data_objects/user.rb', line 65

def logged_in?
  welcome=@browser.span(:class=>"welcome")
  if welcome.present?
    welcome.text=~/#{@first_name}/ ? true : false
  else
    return false
  end
end

#viewObject



39
40
41
# File 'lib/sambal-cle/data_objects/user.rb', line 39

def view
  # TODO
end