opensupports/tests/scripts.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

class Scripts
def self.createUser(email = 'steve@jobs.com', password = 'custompassword', name = 'steve jobs')
response = request('/user/signup', {
:name => name,
:email => email,
:password => password
})
if response['status'] === 'fail'
raise 'Could not create user'
2016-05-15 01:22:46 +02:00
end
end
def self.login(email = 'steve@jobs.com', password = 'custompassword', staff = false)
request('/user/logout')
response = request('/user/login', {
:email => email,
:password => password,
:staff => staff
})
if response['data'].any?
$csrf_userid = response['data']['userId']
$csrf_token = response['data']['token']
end
response['data']
end
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
end