opensupports/tests/user/delete.rb

31 lines
1.0 KiB
Ruby

describe '/user/delete' do
request('/user/logout')
it 'should delete user' do
Scripts.createUser('deletable@opensupports.com', 'deletable')
Scripts.login('deletable@opensupports.com', 'deletable')
Scripts.createTicket('Ticket that will be deleted')
request('/user/logout')
Scripts.login('staff@opensupports.com', 'staff', true)
ticket = $database.getLastRow('ticket')
deletable_user = $database.getLastRow('user')
result = request('/user/delete', {
userId: deletable_user['id'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
last_ticket = $database.getLastRow('ticket')
last_log = $database.getLastRow('log')
user = $database.getRow('user', deletable_user['id'] , 'id')
(user).should.equal(nil)
(ticket['id']).should.not.equal(last_ticket['id'])
(last_log['type']).should.equal('DELETE_USER')
end
end