2016-08-10 03:55:12 +02:00
|
|
|
describe '/user/edit-email' do
|
|
|
|
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2016-08-10 03:55:12 +02:00
|
|
|
result = request('/user/login', {
|
|
|
|
email: 'steve@jobs.com',
|
2019-02-14 23:43:22 +01:00
|
|
|
password: 'custompassword'
|
2016-08-10 03:55:12 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
$csrf_userid = result['data']['userId']
|
|
|
|
$csrf_token = result['data']['token']
|
|
|
|
|
|
|
|
|
|
|
|
it 'should fail if new email is incorrect' do
|
|
|
|
result = request('/user/edit-email', {
|
|
|
|
newEmail: 'newemail@jobscom',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
2016-08-10 04:54:39 +02:00
|
|
|
})
|
2016-08-10 03:55:12 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-10-04 23:42:47 +02:00
|
|
|
(result['message']).should.equal('INVALID_EMAIL')
|
2016-08-10 03:55:12 +02:00
|
|
|
|
|
|
|
result = request('/user/edit-email', {
|
|
|
|
newEmail: 'newemailjobs.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
2016-08-10 04:54:39 +02:00
|
|
|
})
|
2016-08-10 03:55:12 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-10-04 23:42:47 +02:00
|
|
|
(result['message']).should.equal('INVALID_EMAIL')
|
2016-08-10 03:55:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should change email' do
|
|
|
|
result = request('/user/edit-email', {
|
|
|
|
newEmail: 'newemail@jobs.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
2016-08-10 04:54:39 +02:00
|
|
|
})
|
2016-08-10 03:55:12 +02:00
|
|
|
(result['status']).should.equal('success')
|
2019-02-14 23:43:22 +01:00
|
|
|
|
|
|
|
result = request('/user/edit-email', {
|
|
|
|
newEmail: 'steve@jobs.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
2016-08-10 03:55:12 +02:00
|
|
|
end
|
|
|
|
end
|