Method: UserObject#create

Defined in:
lib/kuality-coeus/data_objects/user/user.rb

#createObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 147

def create
  visit(SystemAdmin).person
  on(PersonLookup).create
  on Person do |add|
    add.expand_all
    add.principal_name.set @user_name
    fill_out add, :description, :affiliation_type, :campus_code, :first_name, :last_name
    # TODO: These "default" checkboxes will need to be reworked if and when
    # a test is going to require multiple affiliations, names, addresses, etc.
    # Until then, there's no need to do anything other than set the necessary single values
    # as "default"...
    add.affiliation_default.set
    add.name_default.set
    add.add_name
    add.add_affiliation
    # TODO: Another thing that will need to be changed if ever there's a need to test multiple
    # lines of employment:
    unless @employee_id.nil?
      fill_out add, :employee_id, :employee_status, :employee_type, :base_salary,
               :primary_department_code
      add.primary_employment.set
      add.add_employment_information
    end
    @roles.each { |role| role.create }
    # TODO: Support groups creation here. For now, use the add_group method.
    unless @addresses.nil?
      @addresses.each do |address|
        add.address_type.fit address[:type]
        add.line_1.fit address[:line_1]
        add.city.fit address[:city]
        add.state.pick! address[:state]
        add.country.pick! address[:country]
        add.zip.fit address[:zip]
        add.address_default.fit address[:default]
        add.add_address
      end
    end
    unless @phones.nil?
      @phones.each do |phone|
        add.phone_type.fit phone[:type]
        add.phone_number.fit phone[:number]
        add.phone_default.fit phone[:default]
        add.add_phone
      end
    end
    unless @emails.nil?
      @emails.each do |email|
        add.email.fit email[:email]
        add.email_type.pick! email[:type]
        add.email_default.fit email[:default]
        add.add_email
      end
    end
    # A breaking of the design pattern, but there's no other
    # way to obtain this number:
    @principal_id = add.principal_id
    add.blanket_approve
  end

  unless extended_attributes.compact.length==0
    visit(SystemAdmin).person_extended_attributes
    on(PersonExtendedAttributesLookup).create
    on PersonExtendedAttributes do |page|
      page.expand_all
      fill_out page, :description, :primary_title, :directory_title, :citizenship_type,
               :era_commons_user_name, :graduate_student_count, :billing_element,
               :principal_id, :directory_department
      page.blanket_approve
    end
  end

end