fix bug 83
This commit is contained in:
parent
02b6993615
commit
3d416f82bd
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue