Ivan - Fix comment bug #27
This commit is contained in:
parent
ed4585dac2
commit
fcb26fab60
|
@ -76,10 +76,12 @@ class CommentController extends Controller {
|
|||
$session = Session::getInstance();
|
||||
$this->requestData();
|
||||
|
||||
if ((!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) || $session->isLoggedWithId(($this->ticket->author) ? $this->ticket->author->id : 0) || (Controller::isStaffLogged() && $session->isLoggedWithId(($this->ticket->owner) ? $this->ticket->owner->id : 0))) {
|
||||
if ((!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) ||
|
||||
(!Controller::isStaffLogged() && $session->isLoggedWithId(($this->ticket->author) ? $this->ticket->author->id : 0)) ||
|
||||
(Controller::isStaffLogged() && $session->isLoggedWithId(($this->ticket->owner) ? $this->ticket->owner->id : 0))) {
|
||||
$this->storeComment();
|
||||
|
||||
if(Controller::isStaffLogged()) {
|
||||
if(Controller::isStaffLogged() || $this->ticket->owner) {
|
||||
$this->sendMail();
|
||||
}
|
||||
|
||||
|
@ -122,9 +124,17 @@ class CommentController extends Controller {
|
|||
private function sendMail() {
|
||||
$mailSender = MailSender::getInstance();
|
||||
|
||||
$email = ($this->ticket->author) ? $this->ticket->author->email : $this->ticket->authorEmail;
|
||||
$name = ($this->ticket->author) ? $this->ticket->author->name : $this->ticket->authorName;
|
||||
|
||||
if(!Controller::isStaffLogged() && $this->ticket->owner) {
|
||||
$email = $this->ticket->owner->email;
|
||||
$name = $this->ticket->owner->name;
|
||||
}
|
||||
|
||||
$mailSender->setTemplate(MailTemplate::TICKET_RESPONDED, [
|
||||
'to' => ($this->ticket->author) ? $this->ticket->author->email : $this->ticket->authorEmail,
|
||||
'name' => ($this->ticket->author) ? $this->ticket->author->name : $this->ticket->authorName,
|
||||
'to' => $email,
|
||||
'name' => $name,
|
||||
'ticketNumber' => $this->ticket->ticketNumber,
|
||||
'title' => $this->ticket->title,
|
||||
'url' => Setting::getSetting('url')->getValue()
|
||||
|
|
|
@ -24,7 +24,7 @@ describe'/staff/add' do
|
|||
(row['level']).should.equal('2')
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
(row['owners']).should.equal('3')
|
||||
|
||||
lastLog = $database.getLastRow('log')
|
||||
(lastLog['type']).should.equal('ADD_STAFF')
|
||||
|
@ -46,6 +46,6 @@ describe'/staff/add' do
|
|||
(result['message']).should.equal('ALREADY_A_STAFF')
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
(row['owners']).should.equal('3')
|
||||
end
|
||||
end
|
|
@ -6,29 +6,29 @@ describe'/staff/delete' do
|
|||
result= request('/staff/delete', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
staffId:2
|
||||
staffId: 3
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
row = $database.getRow('staff', 2, 'id')
|
||||
row = $database.getRow('staff', 3, 'id')
|
||||
(row).should.equal(nil)
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
(row['owners']).should.equal('3')
|
||||
|
||||
end
|
||||
it 'should fail delete if staff member is does not exist' do
|
||||
result= request('/staff/delete', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
staffId:2
|
||||
staffId: 3
|
||||
})
|
||||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('INVALID_STAFF')
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
(row['owners']).should.equal('3')
|
||||
end
|
||||
end
|
|
@ -9,22 +9,22 @@ describe'/staff/edit' do
|
|||
email: 'LittleLannister@opensupports.com',
|
||||
level: 1,
|
||||
departments: '[1, 2]',
|
||||
staffId: 2
|
||||
staffId: 3
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
row = $database.getRow('staff', 2, 'id')
|
||||
row = $database.getRow('staff', 3, 'id')
|
||||
|
||||
(row['email']).should.equal('LittleLannister@opensupports.com')
|
||||
(row['level']).should.equal('1')
|
||||
|
||||
rows = $database.getRow('department_staff', 2, 'staff_id')
|
||||
rows = $database.getRow('department_staff', 3, 'staff_id')
|
||||
|
||||
(rows['department_id']).should.equal('1')
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
(row['owners']).should.equal('3')
|
||||
|
||||
row = $database.getRow('department', 2, 'id')
|
||||
(row['owners']).should.equal('2')
|
||||
|
@ -61,7 +61,7 @@ describe'/staff/edit' do
|
|||
(row['send_email_on_new_ticket']).should.equal('1')
|
||||
|
||||
row = $database.getRow('department', 1, 'id')
|
||||
(row['owners']).should.equal('3')
|
||||
(row['owners']).should.equal('4')
|
||||
|
||||
end
|
||||
end
|
|
@ -23,13 +23,13 @@ describe'/staff/get-all' do
|
|||
(result['data'][0]['assignedTickets']).should.equal(3)
|
||||
(result['data'][0]['closedTickets']).should.equal(0)
|
||||
|
||||
(result['data'][1]['name']).should.equal('Arya Stark')
|
||||
(result['data'][1]['email']).should.equal('newwstaff@opensupports.com')
|
||||
(result['data'][1]['profilePic']).should.equal('')
|
||||
(result['data'][1]['level']).should.equal('2')
|
||||
(result['data'][1]['departments'][0]['id']).should.equal('1')
|
||||
(result['data'][1]['departments'][0]['name']).should.equal('Help and Support')
|
||||
(result['data'][1]['assignedTickets']).should.equal(0)
|
||||
(result['data'][1]['closedTickets']).should.equal(0)
|
||||
(result['data'][2]['name']).should.equal('Arya Stark')
|
||||
(result['data'][2]['email']).should.equal('newwstaff@opensupports.com')
|
||||
(result['data'][2]['profilePic']).should.equal('')
|
||||
(result['data'][2]['level']).should.equal('2')
|
||||
(result['data'][2]['departments'][0]['id']).should.equal('1')
|
||||
(result['data'][2]['departments'][0]['name']).should.equal('Help and Support')
|
||||
(result['data'][2]['assignedTickets']).should.equal(0)
|
||||
(result['data'][2]['closedTickets']).should.equal(0)
|
||||
end
|
||||
end
|
|
@ -18,7 +18,7 @@ describe '/staff/get/' do
|
|||
result = request('/staff/get', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
staffId:2
|
||||
staffId: 3
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
|
|
@ -91,9 +91,30 @@ describe '/ticket/comment/' do
|
|||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('NO_PERMISSION')
|
||||
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
request('/staff/add', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
name: 'Jorah mormont',
|
||||
email: 'jorah@opensupports.com',
|
||||
password: 'testpassword',
|
||||
level: 2,
|
||||
profilePic: '',
|
||||
departments: '[1]'
|
||||
})
|
||||
|
||||
request('/user/logout')
|
||||
Scripts.login('jorah@opensupports.com', 'testpassword', true)
|
||||
result = request('/ticket/comment', {
|
||||
content: 'some comment content',
|
||||
ticketNumber: @ticketNumber,
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('NO_PERMISSION')
|
||||
end
|
||||
|
||||
#it 'should add comment if logged as ticket owner' do
|
||||
|
||||
#end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue