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.
*
* @apiUse NO_PERMISSION
* @apiUse INVALID_NAME
*
* @apiSuccess {Object} data Empty object
*
@ -29,20 +28,15 @@ class AddDepartmentController extends Controller {
public function validations() {
return [
'permission' => 'staff_3',
'requestData' => [
'name' => [
'validation' => DataValidator::alnum(),
'error' => ERRORS::INVALID_NAME
]
]
'requestData' => []
];
}
public function handler() {
$name = Controller::request('name');
$departmentInstance = new Department();
$departmentInstance->setProperties([
'name' => $name,
]);
@ -53,4 +47,4 @@ class AddDepartmentController extends Controller {
Response::respondSuccess();
}
}
}

View File

@ -2,7 +2,7 @@ describe'system/add-department' do
request('/user/logout')
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', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
@ -18,4 +18,21 @@ describe'system/add-department' do
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('ADD_DEPARTMENT')
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