Ivan - Add CustomResponse tests [skip ci]

This commit is contained in:
ivan 2016-10-03 16:57:12 -03:00
parent 84b33ea871
commit 684bdb1a25
3 changed files with 59 additions and 2 deletions

View File

@ -6,11 +6,11 @@ use Respect\Validation\Rules\AbstractRule;
class ValidLanguage extends AbstractRule {
//TODO: Use a list from database instead
private $languages = [
'en',
'es',
'de',
'cn',
'de'
];
public function validate($ticketNumber) {

View File

@ -21,4 +21,5 @@ require './user/get.rb'
require './ticket/create.rb'
require './ticket/comment.rb'
require './ticket/get.rb'
require './ticket/custom-response.rb'
require './staff/get.rb'

View File

@ -0,0 +1,56 @@
describe 'CustomResponses' do
Scripts.login('staff@opensupports.com', 'staff', true)
describe '/ticket/add-custom-responses/' do
it 'should create custom response' do
result = request('/ticket/add-custom-response', {
name: 'Some common problem',
language: 'en',
content: 'this is the content of a custom response for a common problem',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
customResponse = $database.getRow('customresponse', 1)
(result['status']).should.equal('success')
(customResponse['name']).should.equal('Some common problem')
(customResponse['content']).should.equal('this is the content of a custom response for a common problem')
(customResponse['language']).should.equal('en')
end
end
describe '/ticket/edit-custom-responses/' do
it 'should edit a custom response' do
result = request('/ticket/edit-custom-response', {
id: 1,
content: 'this is the content of a custom response for a common problem 2',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
customResponse = $database.getRow('customresponse', 1)
(result['status']).should.equal('success')
(customResponse['name']).should.equal('Some common problem')
(customResponse['content']).should.equal('this is the content of a custom response for a common problem 2')
(customResponse['language']).should.equal('en')
end
end
describe '/ticket/get-custom-responses/' do
it 'should return all custom responses' do
result = request('/ticket/get-custom-responses', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(1)
(result['data'][0]['name']).should.equal('Some common problem')
(result['data'][0]['content']).should.equal('this is the content of a custom response for a common problem 2')
(result['data'][0]['language']).should.equal('en')
end
end
end