Ivan - Fix test issues [skip ci]

This commit is contained in:
ivan 2017-02-25 03:42:10 -03:00
parent 5126b40538
commit 7f1047b311
5 changed files with 24 additions and 24 deletions

View File

@ -86,6 +86,6 @@ class TicketGetController extends Controller {
$user = Controller::getLoggedUser();
return (!Controller::isStaffLogged() && (Controller::isUserSystemEnabled() && $this->ticket->author->id !== $user->id)) ||
(Controller::isStaffLogged() && !$user->sharedDepartmentList->includesId($this->ticket->department->id));
(Controller::isStaffLogged() && (($this->ticket->owner && $this->ticket->owner->id !== $user->id) || !$user->sharedDepartmentList->includesId($this->ticket->department->id)));
}
}

View File

@ -46,7 +46,7 @@ class DataStoreList implements IteratorAggregate {
}
public function isEmpty() {
return empty($list);
return empty($this->list);
}
public function toBeanList() {

View File

@ -10,7 +10,7 @@ class Scripts
raise response['message']
end
userRow = $database.getRow('user', email, 'email')
response = request('/user/verify', {
request('/user/verify', {
:email => email,
:token => userRow['verification_token']
})
@ -32,9 +32,9 @@ class Scripts
response['data']
end
def self.createTicket()
def self.createTicket(title = 'Winter is coming')
result = request('/ticket/create', {
title: 'Winter is coming',
title: title,
content: 'The north remembers',
departmentId: 1,
language: 'en',
@ -46,7 +46,7 @@ class Scripts
end
def self.createAPIKey(name)
result = request('/system/add-api-key', {
request('/system/add-api-key', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: name

View File

@ -9,7 +9,6 @@ describe'system/disable-user-system' do
password:$staff[:password]
})
puts result['message']
(result['status']).should.equal('success')
row = $database.getRow('setting', 'user-system-enabled', 'name')
@ -20,7 +19,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL")
(numberOftickets.num_rows).should.equal(35)
(numberOftickets.num_rows).should.equal(36)
request('/user/logout')
@ -63,7 +62,6 @@ describe'system/disable-user-system' do
password:$staff[:password]
})
puts result['message']
(result['status']).should.equal('success')
row = $database.getRow('setting', 'user-system-enabled', 'name')
@ -71,7 +69,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" )
(numberOftickets.num_rows).should.equal(35)
(numberOftickets.num_rows).should.equal(36)
end

View File

@ -1,28 +1,30 @@
describe '/user/delete' do
request('/user/logout')
result = request('/user/login', {
email: 'staff@opensupports.com',
password: 'staff',
staff: true
})
$csrf_userid = result['data']['userId']
$csrf_token = result['data']['token']
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: 4,
userId: deletable_user['id'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
user = $database.getRow('user', 4 , 'id')
(user).should.equal(nil)
last_ticket = $database.getLastRow('ticket')
last_log = $database.getLastRow('log')
user = $database.getRow('user', deletable_user['id'] , 'id')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('DELETE_USER')
(user).should.equal(nil)
(ticket['id']).should.not.equal(last_ticket['id'])
(last_log['type']).should.equal('DELETE_USER')
end
end