2016-12-08 07:21:37 +01:00
|
|
|
describe'/staff/edit' do
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
|
|
|
|
|
|
|
it 'should edit another staff member' do
|
|
|
|
result= request('/staff/edit', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
email: 'LittleLannister@opensupports.com',
|
|
|
|
level: 1,
|
|
|
|
departments: '[1, 2]',
|
2017-06-25 11:07:14 +02:00
|
|
|
staffId: 3
|
2016-12-08 07:21:37 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
2017-06-25 11:07:14 +02:00
|
|
|
row = $database.getRow('staff', 3, 'id')
|
2016-12-08 07:21:37 +01:00
|
|
|
|
|
|
|
(row['email']).should.equal('LittleLannister@opensupports.com')
|
|
|
|
(row['level']).should.equal('1')
|
|
|
|
|
2017-06-25 11:07:14 +02:00
|
|
|
rows = $database.getRow('department_staff', 3, 'staff_id')
|
2016-12-08 07:21:37 +01:00
|
|
|
|
|
|
|
(rows['department_id']).should.equal('1')
|
|
|
|
|
2016-12-10 23:06:21 +01:00
|
|
|
row = $database.getRow('department', 1, 'id')
|
2017-06-25 11:07:14 +02:00
|
|
|
(row['owners']).should.equal('3')
|
2016-12-10 23:06:21 +01:00
|
|
|
|
|
|
|
row = $database.getRow('department', 2, 'id')
|
|
|
|
(row['owners']).should.equal('2')
|
|
|
|
|
2016-12-08 07:21:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should edit staff member ' do
|
|
|
|
request('/staff/add', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
name: 'Arya Stark',
|
|
|
|
password: 'starkpassword',
|
|
|
|
email: 'arya@opensupports.com',
|
|
|
|
level: 2,
|
2017-02-18 19:55:09 +01:00
|
|
|
profilePic: '',
|
2016-12-08 07:21:37 +01:00
|
|
|
departments: '[1]'
|
|
|
|
})
|
|
|
|
request('/user/logout')
|
|
|
|
Scripts.login('arya@opensupports.com', 'starkpassword', true)
|
|
|
|
|
|
|
|
result = request('/staff/edit', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token,
|
|
|
|
email: 'newwstaff@opensupports.com',
|
2017-06-28 10:52:45 +02:00
|
|
|
sendEmailOnNewTicket: 1
|
2016-12-08 07:21:37 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
row = $database.getRow('staff', $csrf_userid, 'id')
|
|
|
|
|
|
|
|
(row['email']).should.equal('newwstaff@opensupports.com')
|
|
|
|
(row['level']).should.equal('2')
|
2017-06-10 08:27:22 +02:00
|
|
|
(row['send_email_on_new_ticket']).should.equal('1')
|
2016-12-08 07:21:37 +01:00
|
|
|
|
2016-12-10 23:06:21 +01:00
|
|
|
row = $database.getRow('department', 1, 'id')
|
2017-06-25 11:07:14 +02:00
|
|
|
(row['owners']).should.equal('4')
|
2016-12-10 23:06:21 +01:00
|
|
|
|
2016-12-08 07:21:37 +01:00
|
|
|
end
|
|
|
|
end
|