From 787bd9a42bbfddef9095ba520ffe9c75e1bb268e Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 12 Jul 2018 02:08:37 -0300 Subject: [PATCH] test of feature #101 --- tests/scripts.rb | 10 ++++++++++ tests/ticket/close.rb | 26 ++++++++++++++++++++++++-- tests/ticket/re-open.rb | 26 ++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/tests/scripts.rb b/tests/scripts.rb index 0c0d70be..50e0d8cb 100644 --- a/tests/scripts.rb +++ b/tests/scripts.rb @@ -69,6 +69,16 @@ class Scripts result['data'] end + def self.closeTicket(ticketNumber) + result = request('/ticket/close', { + ticketNumber:ticketNumber, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + result['data'] + end + def self.createAPIKey(name) request('/system/add-api-key', { csrf_userid: $csrf_userid, diff --git a/tests/ticket/close.rb b/tests/ticket/close.rb index 6c7d219d..d44c506e 100644 --- a/tests/ticket/close.rb +++ b/tests/ticket/close.rb @@ -2,8 +2,6 @@ describe '/ticket/close' do request('/user/logout') Scripts.login($staff[:email], $staff[:password], true) - #TODO: DO THINGS - it 'should close a ticket if everything is okey' do ticket = $database.getRow('ticket', 1 , 'id') @@ -21,5 +19,29 @@ describe '/ticket/close' do lastLog = $database.getLastRow('log') (lastLog['type']).should.equal('CLOSE') + + request('/user/logout') + Scripts.createUser('closer@os4.com','closer','Closer') + Scripts.login('closer@os4.com','closer') + Scripts.createTicket('tickettoclose') + + ticket = $database.getRow('ticket', 'tickettoclose', 'title') + + result = request('/ticket/close', { + ticketNumber: ticket['ticket_number'], + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + + }) + + (result['status']).should.equal('success') + + ticket = $database.getRow('ticket', 'tickettoclose', 'title') + (ticket['closed']).should.equal('1') + (ticket['unread']).should.equal('1') + + lastLog = $database.getLastRow('log') + (lastLog['type']).should.equal('CLOSE') + end end diff --git a/tests/ticket/re-open.rb b/tests/ticket/re-open.rb index df3288d7..96f42153 100644 --- a/tests/ticket/re-open.rb +++ b/tests/ticket/re-open.rb @@ -2,8 +2,6 @@ describe '/ticket/re-open' do request('/user/logout') Scripts.login($staff[:email], $staff[:password], true) - #TODO: DO THINGS - it 'should re open a ticket if everything is okey' do ticket = $database.getRow('ticket', 1 , 'id') @@ -21,5 +19,29 @@ describe '/ticket/re-open' do lastLog = $database.getLastRow('log') (lastLog['type']).should.equal('RE_OPEN') + + request('/user/logout') + Scripts.createUser('reopener@os4.com','reopener','Reopener') + Scripts.login('reopener@os4.com','reopener') + Scripts.createTicket('tickettoreopen') + + ticket = $database.getRow('ticket', 'tickettoreopen', 'title') + + Scripts.closeTicket(ticket['ticketNumber']) + + result = request('/ticket/re-open', { + ticketNumber: ticket['ticket_number'], + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + (result['status']).should.equal('success') + + ticket = $database.getRow('ticket', 'tickettoreopen', 'title') + (ticket['closed']).should.equal('0') + (ticket['unread']).should.equal('1') + + lastLog = $database.getLastRow('log') + (lastLog['type']).should.equal('RE_OPEN') end end