2016-12-01 19:07:11 +01:00
|
|
|
describe '/user/delete' do
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2016-12-01 19:07:11 +01:00
|
|
|
|
|
|
|
it 'should delete user' do
|
2017-02-25 07:42:10 +01:00
|
|
|
Scripts.createUser('deletable@opensupports.com', 'deletable')
|
|
|
|
Scripts.login('deletable@opensupports.com', 'deletable')
|
|
|
|
Scripts.createTicket('Ticket that will be deleted')
|
|
|
|
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2021-11-11 21:17:39 +01:00
|
|
|
Scripts.login($staff[:email], $staff[:password], true)
|
2017-02-25 07:42:10 +01:00
|
|
|
ticket = $database.getLastRow('ticket')
|
|
|
|
deletable_user = $database.getLastRow('user')
|
|
|
|
|
2016-12-01 19:07:11 +01:00
|
|
|
result = request('/user/delete', {
|
2017-02-25 07:42:10 +01:00
|
|
|
userId: deletable_user['id'],
|
2016-12-01 19:07:11 +01:00
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
2017-02-25 07:42:10 +01:00
|
|
|
last_ticket = $database.getLastRow('ticket')
|
|
|
|
last_log = $database.getLastRow('log')
|
|
|
|
user = $database.getRow('user', deletable_user['id'] , 'id')
|
2016-12-01 19:07:11 +01:00
|
|
|
|
2017-02-25 07:42:10 +01:00
|
|
|
(user).should.equal(nil)
|
|
|
|
(ticket['id']).should.not.equal(last_ticket['id'])
|
|
|
|
(last_log['type']).should.equal('DELETE_USER')
|
2016-12-01 19:07:11 +01:00
|
|
|
end
|
|
|
|
end
|