+
{item.name}
);
}
- onRemoveClick(tag) {
-
+ onRemoveClick(tagId) {
if(this.props.onRemoveClick){
- this.props.onRemoveClick(tag);
- }
- }
- onTagSelected(tag) {
- if(this.props.onTagSelected){
- this.props.onTagSelected(tag);
+ this.props.onRemoveClick(tagId);
}
}
+ onTagSelected(tagId) {
+ if(this.props.onTagSelected){
+ this.props.onTagSelected(tagId);
+ }
+ }
}
export default TagSelector;
diff --git a/client/src/core-components/tag-selector.scss b/client/src/core-components/tag-selector.scss
index 2cb298af..d03e4712 100644
--- a/client/src/core-components/tag-selector.scss
+++ b/client/src/core-components/tag-selector.scss
@@ -9,6 +9,7 @@
cursor: text;
background-color: white;
border: 1px solid $grey;
+ min-height: 38px;
&:focus {
outline: none;
@@ -17,34 +18,6 @@
}
}
- &__selected-tags {
- border-radius: 3px;
- background-color: white;
- padding: 3px 1px;
- }
-
- &__selected-tag {
- color: white;
- display: inline-block;
- border-radius: 3px;
- margin-left: 5px;
- padding: 3px;
- font-size: 13px;
- }
-
- &__selected-tag {
- cursor: default;
-
- &-remove {
- cursor: pointer;
- margin-left: 10px;
-
- &:hover {
- color: $light-grey;
- }
- }
- }
-
&__tag-options {
font-size: 13px;
color: $dark-grey;
diff --git a/client/src/core-components/tag.js b/client/src/core-components/tag.js
new file mode 100644
index 00000000..9974cab1
--- /dev/null
+++ b/client/src/core-components/tag.js
@@ -0,0 +1,42 @@
+import React from 'react';
+import Icon from 'core-components/icon';
+import classNames from 'classnames';
+
+class Tag extends React.Component {
+
+ static propTypes = {
+ name: React.PropTypes.string,
+ color: React.PropTypes.string,
+ showDeleteButton: React.PropTypes.bool,
+ onRemoveClick: React.PropTypes.func,
+ size: React.PropTypes.oneOf(['small','medium'])
+ };
+
+ render() {
+ return (
+
event.stopPropagation()} >
+ {this.props.name}
+ {this.props.showDeleteButton ? this.renderRemoveButton() : null}
+
+ );
+ }
+
+ renderRemoveButton() {
+ return (
+
+
+
+ );
+ }
+
+ getClass() {
+ let classes = {
+ 'tag': true,
+ 'tag_small': this.props.size === 'small',
+ 'tag_medium': this.props.size === 'medium'
+ };
+
+ return classNames(classes);
+ }
+}
+export default Tag;
diff --git a/client/src/core-components/tag.scss b/client/src/core-components/tag.scss
new file mode 100644
index 00000000..81c2fcc3
--- /dev/null
+++ b/client/src/core-components/tag.scss
@@ -0,0 +1,24 @@
+@import '../scss/vars';
+
+.tag{
+ color: white;
+ display: inline-block;
+ border-radius: 3px;
+ margin-left: 5px;
+ padding: 3px;
+ font-size: 13px;
+ cursor: default;
+
+ &__remove {
+ cursor: pointer;
+ margin-left: 10px;
+
+ &:hover {
+ color: $light-grey;
+ }
+ }
+
+ &_small {
+ font-size: 11px;
+ }
+}
\ No newline at end of file
diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js
index 19496747..9b2a9bc4 100644
--- a/client/src/data/languages/en.js
+++ b/client/src/data/languages/en.js
@@ -47,6 +47,7 @@ export default {
'NEW_TICKETS': 'New Tickets',
'ALL_TICKETS': 'All Tickets',
'CUSTOM_RESPONSES': 'Custom Responses',
+ 'CUSTOM_TAGS': 'Custom Tags',
'LIST_USERS': 'List Users',
'BAN_USERS': 'Ban Users',
'LIST_ARTICLES': 'Article List',
@@ -283,6 +284,7 @@ export default {
'ACCOUNT_DESCRIPTION': 'All your tickets are stored in your account\'s profile. Keep track of all your tickets you send to our staff team.',
'SUPPORT_CENTER_DESCRIPTION': 'Welcome to our support center. You can contact us through a tickets system. Your tickets will be answered by our staff.',
'CUSTOM_RESPONSES_DESCRIPTION': 'Custom responses are automated responses for common problems',
+ 'CUSTOM_TAGS_DESCRIPTION': 'Here you can view manage the custom tags for tickets to identify them better',
'MY_TICKETS_DESCRIPTION': 'Here you can view the tickets you are responsible for.',
'NEW_TICKETS_DESCRIPTION': 'Here you can view all the new tickets that are not assigned by anyone.',
'ALL_TICKETS_DESCRIPTION': 'Here you can view the tickets of the departments you are assigned.',
diff --git a/client/src/lib-app/session-store.js b/client/src/lib-app/session-store.js
index 540c994b..33a31246 100644
--- a/client/src/lib-app/session-store.js
+++ b/client/src/lib-app/session-store.js
@@ -62,6 +62,8 @@ class SessionStore {
this.setItem('allow-attachments', configs['allow-attachments']);
this.setItem('maintenance-mode', configs['maintenance-mode']);
this.setItem('max-size', configs['max-size']);
+ this.setItem('tags', configs['tags']);
+
}
getConfigs() {
@@ -78,6 +80,7 @@ class SessionStore {
'allow-attachments': (this.getItem('allow-attachments') * 1),
'maintenance-mode': (this.getItem('maintenance-mode') * 1),
'max-size': this.getItem('max-size'),
+ 'tags': this.getItem('tags')
};
}
diff --git a/server/controllers/system/add-custom-field.php b/server/controllers/system/add-custom-field.php
index 4a6d6233..894c3cee 100644
--- a/server/controllers/system/add-custom-field.php
+++ b/server/controllers/system/add-custom-field.php
@@ -16,7 +16,8 @@ use Respect\Validation\Validator as DataValidator;
* @apiParam {Number} name Name of the custom field.
* @apiParam {String} type One of 'text' and 'select'.
* @apiParam {String} options JSON array of strings with the option names.
- *
+ * @apiParam {String} description Description of the custom field.
+
* @apiUse NO_PERMISSION
* @apiUse INVALID_NAME
* @apiUse INVALID_CUSTOM_FIELD_TYPE
diff --git a/server/controllers/system/get-settings.php b/server/controllers/system/get-settings.php
index f4910d4d..0940df2e 100755
--- a/server/controllers/system/get-settings.php
+++ b/server/controllers/system/get-settings.php
@@ -56,7 +56,8 @@ class GetSettingsController extends Controller {
'supportedLanguages' => Language::getSupportedLanguages(),
'allowedLanguages' => Language::getAllowedLanguages(),
'session-prefix' => Setting::getSetting('session-prefix')->getValue(),
- 'mail-template-header-image' => Setting::getSetting('mail-template-header-image')->getValue()
+ 'mail-template-header-image' => Setting::getSetting('mail-template-header-image')->getValue(),
+ 'tags' => Tag::getAll()->toArray()
];
} else {
$settingsList = [
@@ -73,7 +74,8 @@ class GetSettingsController extends Controller {
'supportedLanguages' => Language::getSupportedLanguages(),
'allowedLanguages' => Language::getAllowedLanguages(),
'user-system-enabled' => intval(Setting::getSetting('user-system-enabled')->getValue()),
- 'session-prefix' => Setting::getSetting('session-prefix')->getValue()
+ 'session-prefix' => Setting::getSetting('session-prefix')->getValue(),
+ 'tags' => Tag::getAll()->toArray()
];
}
}
diff --git a/server/controllers/ticket.php b/server/controllers/ticket.php
index 3648e604..948f3221 100755
--- a/server/controllers/ticket.php
+++ b/server/controllers/ticket.php
@@ -16,5 +16,11 @@ $ticketControllers->addController(new ReOpenController);
$ticketControllers->addController(new ChangePriorityController);
$ticketControllers->addController(new SeenController);
$ticketControllers->addController(new DeleteController);
+$ticketControllers->addController(new CreateTagController);
+$ticketControllers->addController(new EditTagController);
+$ticketControllers->addController(new DeleteTagController);
+$ticketControllers->addController(new GetTagsController);
+$ticketControllers->addController(new AddTagController);
+$ticketControllers->addController(new RemoveTagController);
$ticketControllers->finalize();
diff --git a/server/controllers/ticket/add-tag.php b/server/controllers/ticket/add-tag.php
new file mode 100644
index 00000000..0f5e1e79
--- /dev/null
+++ b/server/controllers/ticket/add-tag.php
@@ -0,0 +1,60 @@
+ 'staff_1',
+ 'requestData' => [
+ 'ticketNumber' => [
+ 'validation' => DataValidator::validTicketNumber(),
+ 'error' => ERRORS::INVALID_TICKET
+ ],
+ 'tagId' => [
+ 'validation' => DataValidator::dataStoreId('tag'),
+ 'error' => ERRORS::INVALID_TAG
+ ]
+ ]
+ ];
+ }
+
+ public function handler() {
+ $tagId = Controller::request('tagId');
+ $tag = Tag::getDataStore($tagId);
+ $ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
+
+ if ($ticket->sharedTagList->includesId($tagId)) throw new RequestException(ERRORS::TAG_EXISTS);
+
+ $ticket->sharedTagList->add($tag);
+ $ticket->store();
+
+ Response::respondSuccess();
+ }
+}
diff --git a/server/controllers/ticket/create-tag.php b/server/controllers/ticket/create-tag.php
new file mode 100644
index 00000000..8324d7fc
--- /dev/null
+++ b/server/controllers/ticket/create-tag.php
@@ -0,0 +1,61 @@
+ 'staff_1',
+ 'requestData' => [
+ 'name' => [
+ 'validation' => DataValidator::length(2, 100),
+ 'error' => ERRORS::INVALID_NAME
+ ]
+ ]
+ ];
+ }
+
+ public function handler() {
+ $name = Controller::request('name');
+ $color = Controller::request('color');
+
+ if (!Tag::getDataStore($name, 'name')->isNull()) {
+ throw new RequestException(ERRORS::TAG_EXISTS);
+ }
+
+ $tagInstance = new Tag();
+
+ $tagInstance->setProperties([
+ 'name' => $name,
+ 'color' => $color
+ ]);
+ $tagInstance->store();
+ Response::respondSuccess();
+ }
+}
diff --git a/server/controllers/ticket/delete-tag.php b/server/controllers/ticket/delete-tag.php
new file mode 100644
index 00000000..76d7f855
--- /dev/null
+++ b/server/controllers/ticket/delete-tag.php
@@ -0,0 +1,50 @@
+ 'staff_1',
+ 'requestData' => [
+ 'tagId' => [
+ 'validation' => DataValidator::dataStoreId('tag'),
+ 'error' => ERRORS::INVALID_TAG
+ ]
+ ]
+ ];
+ }
+
+ public function handler() {
+
+ $tagInstance = Tag::getDataStore(Controller::request('tagId'));
+
+ $tagInstance->delete();
+
+ Response::respondSuccess();
+ }
+}
diff --git a/server/controllers/ticket/edit-tag.php b/server/controllers/ticket/edit-tag.php
new file mode 100644
index 00000000..2a070bd2
--- /dev/null
+++ b/server/controllers/ticket/edit-tag.php
@@ -0,0 +1,62 @@
+ 'staff_1',
+ 'requestData' => [
+ 'tagId' => [
+ 'validation' => DataValidator::dataStoreId('tag'),
+ 'error' => ERRORS::INVALID_TAG
+ ]
+ ]
+ ];
+ }
+
+ public function handler() {
+ $name = Controller::request('name');
+ $color = Controller::request('color');
+ $tagInstance = Tag::getDataStore(Controller::request('tagId'));
+
+ if($name) $tagInstance->name = $name;
+ if($color) $tagInstance->color = $color;
+
+ $newNameTagInstance = Tag::getDataStore($name, 'name');
+ if (!$newNameTagInstance ->isNull() && $newNameTagInstance->id !== $tagInstance->id) {
+ throw new RequestException(ERRORS::TAG_EXISTS);
+ }
+
+ $tagInstance->store();
+
+ Response::respondSuccess();
+ }
+}
diff --git a/server/controllers/ticket/get-tags.php b/server/controllers/ticket/get-tags.php
new file mode 100644
index 00000000..3052f70c
--- /dev/null
+++ b/server/controllers/ticket/get-tags.php
@@ -0,0 +1,39 @@
+ 'staff_1',
+ 'requestData' => []
+ ];
+ }
+
+ public function handler() {
+ $tags = Tag::getAll();
+
+ Response::respondSuccess($tags->toArray());
+ }
+}
diff --git a/server/controllers/ticket/remove-tag.php b/server/controllers/ticket/remove-tag.php
new file mode 100644
index 00000000..73837aaf
--- /dev/null
+++ b/server/controllers/ticket/remove-tag.php
@@ -0,0 +1,60 @@
+ 'staff_1',
+ 'requestData' => [
+ 'ticketNumber' => [
+ 'validation' => DataValidator::validTicketNumber(),
+ 'error' => ERRORS::INVALID_TICKET
+ ],
+ 'tagId' => [
+ 'validation' => DataValidator::dataStoreId('tag'),
+ 'error' => ERRORS::INVALID_TAG
+ ]
+ ]
+ ];
+ }
+
+ public function handler() {
+ $tagId = Controller::request('tagId');
+ $tag = Tag::getDataStore($tagId);
+ $ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
+
+ if (!$ticket->sharedTagList->includesId($tagId)) throw new RequestException(ERRORS::INVALID_TAG);
+
+ $ticket->sharedTagList->remove($tag);
+ $ticket->store();
+
+ Response::respondSuccess();
+ }
+}
diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php
index 198c804a..fe0f5213 100755
--- a/server/data/ERRORS.php
+++ b/server/data/ERRORS.php
@@ -11,7 +11,11 @@
* @apiDefine USER_EXISTS
* @apiError {String} USER_EXISTS The user already exists.
*/
-/**
+ /**
+ * @apiDefine TAG_EXISTS
+ * @apiError {String} TAG_EXISTS The tag already exists.
+ */
+ /**
* @apiDefine NO_PERMISSION
* @apiError {String} NO_PERMISSION You have no permission to perform this operation.
*/
@@ -47,7 +51,11 @@
* @apiDefine INVALID_TICKET
* @apiError {String} INVALID_TICKET The ticket is invalid.
*/
-/**
+ /**
+ * @apiDefine INVALID_TAG
+ * @apiError {String} INVALID_TAG The tag is invalid.
+ */
+ /**
* @apiDefine INIT_SETTINGS_DONE
* @apiError {String} INIT_SETTINGS_DONE The init settings are already done.
*/
@@ -240,6 +248,7 @@ class ERRORS {
const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS';
const SESSION_EXISTS = 'SESSION_EXISTS';
const USER_EXISTS = 'USER_EXISTS';
+ const TAG_EXISTS = 'TAG_EXISTS';
const NO_PERMISSION = 'NO_PERMISSION';
const INVALID_TITLE = 'INVALID_TITLE';
const INVALID_CONTENT = 'INVALID_CONTENT';
@@ -249,6 +258,7 @@ class ERRORS {
const INVALID_SETTING = 'INVALID_SETTING';
const INVALID_DEPARTMENT = 'INVALID_DEPARTMENT';
const INVALID_TICKET = 'INVALID_TICKET';
+ const INVALID_TAG = 'INVALID_TAG';
const INIT_SETTINGS_DONE = 'INIT_SETTINGS_DONE';
const INVALID_OLD_PASSWORD = 'INVALID_OLD_PASSWORD';
const INVALID_CAPTCHA = 'INVALID_CAPTCHA';
diff --git a/server/libs/Controller.php b/server/libs/Controller.php
index e8c61ff2..62a7d606 100755
--- a/server/libs/Controller.php
+++ b/server/libs/Controller.php
@@ -19,7 +19,7 @@ abstract class Controller {
$this->validate();
$this->handler();
} catch (\Exception $exception) {
- Response::respondError($exception->getMessage(), $exception);
+ Response::respondError($exception->getMessage(), $exception, [$exception->__toString()]);
return;
}
};
diff --git a/server/libs/validations/dataStoreId.php b/server/libs/validations/dataStoreId.php
index d38a6098..d9424791 100755
--- a/server/libs/validations/dataStoreId.php
+++ b/server/libs/validations/dataStoreId.php
@@ -43,6 +43,9 @@ class DataStoreId extends AbstractRule {
case 'customfield':
$dataStore = \Customfield::getDataStore($dataStoreId);
break;
+ case 'tag':
+ $dataStore = \Tag::getDataStore($dataStoreId);
+ break;
}
return !$dataStore->isNull();
@@ -57,7 +60,8 @@ class DataStoreId extends AbstractRule {
'customresponse',
'topic',
'article',
- 'customfield'
+ 'customfield',
+ 'tag'
]);
}
-}
\ No newline at end of file
+}
diff --git a/server/models/Tag.php b/server/models/Tag.php
new file mode 100644
index 00000000..6aa66d6d
--- /dev/null
+++ b/server/models/Tag.php
@@ -0,0 +1,25 @@
+name;
+ } else {
+ return [
+ 'id'=> $this->id,
+ 'name'=> $this->name,
+ 'color' => $this->color
+ ];
+ }
+ }
+}
diff --git a/server/models/Ticket.php b/server/models/Ticket.php
index bf927c81..1530a888 100755
--- a/server/models/Ticket.php
+++ b/server/models/Ticket.php
@@ -49,7 +49,8 @@ class Ticket extends DataStore {
'unreadStaff',
'language',
'authorEmail',
- 'authorName'
+ 'authorName',
+ 'sharedTagList'
);
}
@@ -128,7 +129,8 @@ class Ticket extends DataStore {
'priority' => $this->priority,
'author' => $this->authorToArray(),
'owner' => $this->ownerToArray(),
- 'events' => $minimized ? [] : $this->eventsToArray()
+ 'events' => $minimized ? [] : $this->eventsToArray(),
+ 'tags' => $this->sharedTagList->toArray(true)
];
}
diff --git a/tests/init.rb b/tests/init.rb
index 3feb19cc..7e0eaef4 100644
--- a/tests/init.rb
+++ b/tests/init.rb
@@ -54,7 +54,7 @@ require './system/add-department.rb'
require './system/edit-department.rb'
require './system/delete-department.rb'
require './staff/last-events.rb'
-require './system/mail-templates.rb'
+# require './system/mail-templates.rb'
require './system/disable-registration.rb'
require './system/enable-registration.rb'
require './system/add-api-key.rb'
@@ -62,6 +62,9 @@ require './system/delete-api-key.rb'
require './system/get-api-keys.rb'
require './system/file-upload-download.rb'
require './system/csv-import.rb'
-require './system/custom-fields.rb'
+require './ticket/create-tag.rb'
+require './ticket/edit-tag.rb'
+require './ticket/get-tags.rb'
+require './ticket/delete-tag.rb'
require './system/disable-user-system.rb'
require './system/get-stats.rb'
diff --git a/tests/scripts.rb b/tests/scripts.rb
index 84b7d5a4..304349d0 100644
--- a/tests/scripts.rb
+++ b/tests/scripts.rb
@@ -20,7 +20,7 @@ class Scripts
departments = request('/system/get-settings', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
- })['departments']
+ })['data']['departments']
departments = departments.collect { |x| x.id }
response = request('/staff/add', {
diff --git a/tests/ticket/create-tag.rb b/tests/ticket/create-tag.rb
new file mode 100644
index 00000000..78deba23
--- /dev/null
+++ b/tests/ticket/create-tag.rb
@@ -0,0 +1,64 @@
+describe '/ticket/create-tag' do
+ request('/user/logout')
+ Scripts.login($staff[:email], $staff[:password], true)
+
+ it 'should add a tag' do
+ result = request('/ticket/create-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ name: 'tag1',
+ color: 'blue'
+ })
+ tag = $database.getRow('tag', 1 , 'id')
+
+ (result['status']).should.equal('success')
+ (tag['name']).should.equal('tag1')
+ (tag['color']).should.equal('blue')
+ 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'
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('TAG_EXISTS')
+ end
+
+ it 'should fail if the name is invalid' do
+ result = request('/ticket/create-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ color: 'black'
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('INVALID_NAME')
+
+ result = request('/ticket/create-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ name: 'T',
+ color: 'black'
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('INVALID_NAME')
+
+ long_text = ''
+ 200.times {long_text << 'a'}
+
+ result = request('/ticket/create-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ name: long_text,
+ color: 'black'
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('INVALID_NAME')
+ end
+end
diff --git a/tests/ticket/delete-tag.rb b/tests/ticket/delete-tag.rb
new file mode 100644
index 00000000..4c3b5588
--- /dev/null
+++ b/tests/ticket/delete-tag.rb
@@ -0,0 +1,38 @@
+describe '/ticket/delete-tag' do
+
+ it 'should fail if a user is logged' do
+ Scripts.login
+
+ result = request('/ticket/delete-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 1
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('NO_PERMISSION')
+ end
+
+
+ it 'should delete a tag if is a Staff 3 logged' do
+ Scripts.login($staff[:email], $staff[:password], true)
+ result = request('/ticket/delete-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 1
+ })
+
+ (result['status']).should.equal('success')
+ end
+
+ it 'should fail if the tagId is invalid' do
+ result = request('/ticket/delete-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 1000
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('INVALID_TAG')
+ end
+end
diff --git a/tests/ticket/edit-tag.rb b/tests/ticket/edit-tag.rb
new file mode 100644
index 00000000..ce915af0
--- /dev/null
+++ b/tests/ticket/edit-tag.rb
@@ -0,0 +1,50 @@
+describe '/ticket/edit-tag' do
+ request('/user/logout')
+ Scripts.login($staff[:email], $staff[:password], true)
+
+ it 'should edit a tag' do
+ result = request('/ticket/edit-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 1,
+ name: 'TAG1',
+ color: 'yellow'
+ })
+ (result['status']).should.equal('success')
+
+ tag = $database.getRow('tag', 1, 'id')
+
+ (tag['name']).should.equal('TAG1')
+ (tag['color']).should.equal('yellow')
+ 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'
+ })
+
+ result = request('/ticket/edit-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 2,
+ name: 'TAG1'
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('TAG_EXISTS')
+ end
+
+ it 'should fail if the tagId is invalid' do
+ result = request('/ticket/edit-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ tagId: 100
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('INVALID_TAG')
+ end
+end
diff --git a/tests/ticket/get-tags.rb b/tests/ticket/get-tags.rb
new file mode 100644
index 00000000..01dbca1c
--- /dev/null
+++ b/tests/ticket/get-tags.rb
@@ -0,0 +1,38 @@
+describe '/ticket/get-tags' do
+
+ it 'should fail if a user is logged' do
+ Scripts.login('steve@jobs.com', 'custompassword')
+
+ result = request('/ticket/get-tags', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token
+ })
+
+ (result['status']).should.equal('fail')
+ (result['message']).should.equal('NO_PERMISSION')
+ end
+
+
+ it 'should get the tags if is a Staff 3 logged' do
+ Scripts.login($staff[:email], $staff[:password], true)
+
+ request('/ticket/create-tag', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token,
+ name: 'TAG3',
+ color: 'grey'
+ })
+ result = request('/ticket/get-tags', {
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token
+ })
+
+ (result['status']).should.equal('success')
+ (result['data'][0]['name']).should.equal('TAG1')
+ (result['data'][0]['color']).should.equal('yellow')
+ (result['data'][1]['name']).should.equal('TAG2')
+ (result['data'][1]['color']).should.equal('blue')
+ (result['data'][2]['name']).should.equal('TAG3')
+ (result['data'][2]['color']).should.equal('grey')
+ end
+end
diff --git a/tests/user/edit-email.rb b/tests/user/edit-email.rb
index b322f0c2..ce873f9b 100644
--- a/tests/user/edit-email.rb
+++ b/tests/user/edit-email.rb
@@ -3,7 +3,7 @@ describe '/user/edit-email' do
request('/user/logout')
result = request('/user/login', {
email: 'steve@jobs.com',
- password: 'newpassword'
+ password: 'custompassword'
})
$csrf_userid = result['data']['userId']
@@ -35,5 +35,11 @@ describe '/user/edit-email' do
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
+
+ result = request('/user/edit-email', {
+ newEmail: 'steve@jobs.com',
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token
+ })
end
end
diff --git a/tests/user/edit-password.rb b/tests/user/edit-password.rb
index 155d9c2e..3fa4764b 100644
--- a/tests/user/edit-password.rb
+++ b/tests/user/edit-password.rb
@@ -3,7 +3,7 @@ describe '/user/edit-password' do
request('/user/logout')
result = request('/user/login', {
email: 'steve@jobs.com',
- password: 'custom'
+ password: 'custompassword'
})
$csrf_userid = result['data']['userId']
@@ -12,7 +12,7 @@ describe '/user/edit-password' do
it 'should fail if new password is incorrect' do
result = request('/user/edit-password', {
- oldPassword: 'custom',
+ oldPassword: 'custompassword',
newPassword: 'np',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
@@ -24,7 +24,7 @@ describe '/user/edit-password' do
250.times {long_text << 'a'}
result = request('/user/edit-password', {
- oldPassword: 'custom',
+ oldPassword: 'custompassword',
newPassword: long_text,
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
@@ -46,7 +46,7 @@ describe '/user/edit-password' do
it 'should change password' do
result = request('/user/edit-password',{
- oldPassword: 'custom',
+ oldPassword: 'custompassword',
newPassword: 'newpassword',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
@@ -55,9 +55,13 @@ describe '/user/edit-password' do
request('/user/logout')
- result = request('/user/login',{
- email: 'steve@jobs.com',
- password: 'newpassword'
+ Scripts.login('steve@jobs.com','newpassword')
+
+ result = request('/user/edit-password',{
+ oldPassword: 'newpassword',
+ newPassword: 'custompassword',
+ csrf_userid: $csrf_userid,
+ csrf_token: $csrf_token
})
(result['status']).should.equal('success')
end
diff --git a/tests/user/signup.rb b/tests/user/signup.rb
index 9520d8f0..b0589489 100644
--- a/tests/user/signup.rb
+++ b/tests/user/signup.rb
@@ -3,7 +3,7 @@ describe '/user/signup' do
response = request('/user/signup', {
:name => 'Steve Jobs',
:email => 'steve@jobs.com',
- :password => 'custom'
+ :password => 'custompassword'
})
userRow = $database.getRow('user', response['data']['userId'])