opensupports/tests/user/delete.rb

31 lines
1020 B
Ruby
Raw Permalink Normal View History

describe '/user/delete' do
Scripts.logout()
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')
Scripts.logout()
Scripts.login($staff[:email], $staff[:password], true)
2017-02-25 07:42:10 +01:00
ticket = $database.getLastRow('ticket')
deletable_user = $database.getLastRow('user')
result = request('/user/delete', {
2017-02-25 07:42:10 +01:00
userId: deletable_user['id'],
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')
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')
end
end