fix bug 83

This commit is contained in:
Guillermo 2018-01-12 23:08:07 -03:00
parent 02b6993615
commit 3d416f82bd
2 changed files with 22 additions and 11 deletions

View File

@ -16,7 +16,6 @@ use Respect\Validation\Validator as DataValidator;
* @apiParam {String} name Name of the new department. * @apiParam {String} name Name of the new department.
* *
* @apiUse NO_PERMISSION * @apiUse NO_PERMISSION
* @apiUse INVALID_NAME
* *
* @apiSuccess {Object} data Empty object * @apiSuccess {Object} data Empty object
* *
@ -29,12 +28,7 @@ class AddDepartmentController extends Controller {
public function validations() { public function validations() {
return [ return [
'permission' => 'staff_3', 'permission' => 'staff_3',
'requestData' => [ 'requestData' => []
'name' => [
'validation' => DataValidator::alnum(),
'error' => ERRORS::INVALID_NAME
]
]
]; ];
} }

View File

@ -2,7 +2,7 @@ describe'system/add-department' do
request('/user/logout') request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true) Scripts.login($staff[:email], $staff[:password], true)
it 'should add department' do it 'should add department with alphanumeric characters' do
result = request('/system/add-department', { result = request('/system/add-department', {
csrf_userid: $csrf_userid, csrf_userid: $csrf_userid,
csrf_token: $csrf_token, csrf_token: $csrf_token,
@ -18,4 +18,21 @@ describe'system/add-department' do
lastLog = $database.getLastRow('log') lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('ADD_DEPARTMENT') (lastLog['type']).should.equal('ADD_DEPARTMENT')
end end
it 'should add department with html tag' do
result = request('/system/add-department', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: '<b>new department</b>'
})
(result['status']).should.equal('success')
row = $database.getRow('department', 5, 'id')
(row['name']).should.equal('<b>new department</b>')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('ADD_DEPARTMENT')
end
end end