Skip to content

Commit

Permalink
Merge pull request opensupports#638 from mredigonda/fix-release-bugs
Browse files Browse the repository at this point in the history
Fix various bugs pre-release 4.5.0
  • Loading branch information
ivandiazwm authored Oct 14, 2019
2 parents d9becc4 + 81a7300 commit a477941
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 21 deletions.
4 changes: 2 additions & 2 deletions server/controllers/ticket/add-custom-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handler() {
$customResponse = new CustomResponse();
$customResponse->setProperties([
'name' => Controller::request('name'),
'content' => Controller::request('content'),
'content' => Controller::request('content', true),
'language' => Controller::request('language')
]);
$customResponse->store();
Expand All @@ -64,4 +64,4 @@ public function handler() {

Response::respondSuccess();
}
}
}
4 changes: 4 additions & 0 deletions server/controllers/ticket/create-tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function validations() {
'name' => [
'validation' => DataValidator::length(2, 100),
'error' => ERRORS::INVALID_NAME
],
'color' => [
'validation' => DataValidator::hexRgbColor()->startsWith('#'),
'error' => ERRORS::INVALID_COLOR
]
]
];
Expand Down
10 changes: 5 additions & 5 deletions server/controllers/ticket/edit-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
*
* @apiGroup Ticket
*
* @apiDescription This path edit a comment.
* @apiDescription This path edits a comment.
*
* @apiPermission user
*
* @apiParam {String} content The new content of the comment.
* @apiParam {Number} ticketEventId The id of the ticket event.
* @apiParam {Number} ticketNumber The id of the ticket number.
* @apiParam {Number} ticketNumber The number of the ticket.
*
* @apiUse NO_PERMISSION
* @apiUse INVALID_CONENT
* @apiUse INVALID_CONTENT
*
* @apiSuccess {Object} data Empty object
*
Expand All @@ -43,7 +43,7 @@ public function validations() {

public function handler() {
$user = Controller::getLoggedUser();
$newcontent = Controller::request('content');
$newcontent = Controller::request('content', true);
$ticketNumberLog = null;

$ticketevent = Ticketevent::getTicketEvent(Controller::request('ticketEventId'));
Expand All @@ -69,7 +69,7 @@ public function handler() {
$ticketevent->content = $newcontent;
$ticketevent->editedContent = true;
$ticketevent->store();
}else{
} else {
$ticketNumber = $ticket->ticketNumber;

$ticket->content = $newcontent;
Expand Down
4 changes: 4 additions & 0 deletions server/controllers/ticket/edit-tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public function validations() {
'tagId' => [
'validation' => DataValidator::dataStoreId('tag'),
'error' => ERRORS::INVALID_TAG
],
'color' => [
'validation' => DataValidator::hexRgbColor()->startsWith('#'),
'error' => ERRORS::INVALID_COLOR
]
]
];
Expand Down
5 changes: 5 additions & 0 deletions server/data/ERRORS.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@
* @apiDefine UNAVAILABLE_STATS
* @apiError {String} UNAVAILABLE_STATS Stats are currently unavailable
*/
/**
* @apiDefine INVALID_COLOR
* @apiError {String} INVALID_COLOR The color should be in hexadecimal, preceded by a '#'
*/

class ERRORS {
const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS';
Expand Down Expand Up @@ -312,4 +316,5 @@ class ERRORS {
const INVALID_CUSTOM_FIELD_OPTIONS = 'INVALID_CUSTOM_FIELD_OPTIONS';
const INVALID_CUSTOM_FIELD_OPTION = 'INVALID_CUSTOM_FIELD_OPTION';
const UNAVAILABLE_STATS = 'UNAVAILABLE_STATS';
const INVALID_COLOR = 'INVALID_COLOR';
}
44 changes: 38 additions & 6 deletions tests/ticket/create-tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'tag1',
color: 'blue'
color: '#0000ff'
})
tag = $database.getRow('tag', 1 , 'id')

(result['status']).should.equal('success')
(tag['name']).should.equal('tag1')
(tag['color']).should.equal('blue')
(tag['color']).should.equal('#0000ff')
end

it 'should not add tag if already exits' do
result = request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'tag1',
color: 'blue'
color: '#ffffff'
})

(result['status']).should.equal('fail')
Expand All @@ -32,7 +32,7 @@
result = request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
color: 'black'
color: '#ffff00'
})

(result['status']).should.equal('fail')
Expand All @@ -42,7 +42,7 @@
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'T',
color: 'black'
color: '#0000ff'
})

(result['status']).should.equal('fail')
Expand All @@ -55,10 +55,42 @@
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: long_text,
color: 'black'
color: '#ffff00'
})

(result['status']).should.equal('fail')
(result['message']).should.equal('INVALID_NAME')
end

it 'should fail if color is invalid' do
result = request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'valid name 1',
color: '00ff00'
})

(result['status']).should.equal('fail')
(result['message']).should.equal('INVALID_COLOR')

result = request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'valid name 2',
color: 'blue'
})

(result['status']).should.equal('fail')
(result['message']).should.equal('INVALID_COLOR')

result = request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'valid name 3',
color: '#00ff00ee'
})

(result['status']).should.equal('fail')
(result['message']).should.equal('INVALID_COLOR')
end
end
9 changes: 5 additions & 4 deletions tests/ticket/edit-tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@
csrf_token: $csrf_token,
tagId: 1,
name: 'TAG1',
color: 'yellow'
color: '#ff00ff'
})
(result['status']).should.equal('success')

tag = $database.getRow('tag', 1, 'id')

(tag['name']).should.equal('TAG1')
(tag['color']).should.equal('yellow')
(tag['color']).should.equal('#ff00ff')
end

it 'should fail if the name already exists' do
request('/ticket/create-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'TAG2',
color: 'blue'
color: '#0000ff'
})

result = request('/ticket/edit-tag', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
tagId: 2,
name: 'TAG1'
name: 'TAG1',
color: '#ff00ff'
})

(result['status']).should.equal('fail')
Expand Down
8 changes: 4 additions & 4 deletions tests/ticket/get-tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: 'TAG3',
color: 'grey'
color: '#dddddd'
})
result = request('/ticket/get-tags', {
csrf_userid: $csrf_userid,
Expand All @@ -29,10 +29,10 @@

(result['status']).should.equal('success')
(result['data'][0]['name']).should.equal('TAG1')
(result['data'][0]['color']).should.equal('yellow')
(result['data'][0]['color']).should.equal('#ff00ff')
(result['data'][1]['name']).should.equal('TAG2')
(result['data'][1]['color']).should.equal('blue')
(result['data'][1]['color']).should.equal('#0000ff')
(result['data'][2]['name']).should.equal('TAG3')
(result['data'][2]['color']).should.equal('grey')
(result['data'][2]['color']).should.equal('#dddddd')
end
end

0 comments on commit a477941

Please sign in to comment.