2016-05-11 03:35:36 +02:00
|
|
|
class Scripts
|
2016-07-19 22:39:26 +02:00
|
|
|
def self.createUser(email = 'steve@jobs.com', password = 'custompassword', name = 'steve jobs')
|
2016-05-11 03:35:36 +02:00
|
|
|
response = request('/user/signup', {
|
2016-08-04 20:18:29 +02:00
|
|
|
:name => name,
|
|
|
|
:email => email,
|
|
|
|
:password => password
|
2016-05-11 03:35:36 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
if response['status'] === 'fail'
|
2016-08-04 20:18:29 +02:00
|
|
|
raise 'Could not create user'
|
2016-05-15 01:22:46 +02:00
|
|
|
end
|
2016-05-11 03:35:36 +02:00
|
|
|
end
|
2016-08-04 20:18:29 +02:00
|
|
|
|
2016-09-25 06:16:10 +02:00
|
|
|
def self.login(email = 'steve@jobs.com', password = 'custompassword', staff = false)
|
2016-08-04 20:18:29 +02:00
|
|
|
request('/user/logout')
|
|
|
|
response = request('/user/login', {
|
|
|
|
:email => email,
|
2016-09-25 06:16:10 +02:00
|
|
|
:password => password,
|
|
|
|
:staff => staff
|
2016-08-04 20:18:29 +02:00
|
|
|
})
|
|
|
|
|
2016-09-09 05:38:58 +02:00
|
|
|
if response['data'].any?
|
|
|
|
$csrf_userid = response['data']['userId']
|
|
|
|
$csrf_token = response['data']['token']
|
|
|
|
end
|
|
|
|
|
2016-08-04 20:18:29 +02:00
|
|
|
response['data']
|
|
|
|
end
|
2016-09-09 05:38:58 +02:00
|
|
|
|
|
|
|
def self.createTicket()
|
|
|
|
result = request('/ticket/create', {
|
|
|
|
title: 'Winter is coming',
|
|
|
|
content: 'The north remembers',
|
|
|
|
departmentId: 1,
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
result['data']
|
|
|
|
end
|
2016-05-11 03:35:36 +02:00
|
|
|
end
|