2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Integration CTI', type: :request do
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
let(:agent) do
|
|
|
|
create(:agent)
|
2018-09-19 13:54:49 +00:00
|
|
|
end
|
2020-06-19 09:17:18 +00:00
|
|
|
let!(:customer1) do
|
2018-09-19 13:54:49 +00:00
|
|
|
create(
|
2020-06-19 09:17:18 +00:00
|
|
|
:customer,
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-caller_id_cti-customer1@example.com',
|
2018-09-19 13:54:49 +00:00
|
|
|
firstname: 'CallerId',
|
2018-12-19 17:31:51 +00:00
|
|
|
lastname: 'Customer1',
|
|
|
|
phone: '+49 99999 222222',
|
|
|
|
fax: '+49 99999 222223',
|
|
|
|
mobile: '+4912347114711',
|
|
|
|
note: 'Phone at home: +49 99999 222224',
|
2018-09-19 13:54:49 +00:00
|
|
|
)
|
|
|
|
end
|
2020-06-19 09:17:18 +00:00
|
|
|
let!(:customer2) do
|
2018-09-19 13:54:49 +00:00
|
|
|
create(
|
2020-06-19 09:17:18 +00:00
|
|
|
:customer,
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-caller_id_cti-customer2@example.com',
|
2018-09-19 13:54:49 +00:00
|
|
|
firstname: 'CallerId',
|
2018-12-19 17:31:51 +00:00
|
|
|
lastname: 'Customer2',
|
|
|
|
phone: '+49 99999 222222 2',
|
2018-09-19 13:54:49 +00:00
|
|
|
)
|
|
|
|
end
|
2020-06-19 09:17:18 +00:00
|
|
|
let!(:customer3) do
|
2018-09-19 13:54:49 +00:00
|
|
|
create(
|
2020-06-19 09:17:18 +00:00
|
|
|
:customer,
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-caller_id_cti-customer3@example.com',
|
2018-09-19 13:54:49 +00:00
|
|
|
firstname: 'CallerId',
|
2018-12-19 17:31:51 +00:00
|
|
|
lastname: 'Customer3',
|
|
|
|
phone: '+49 99999 222222 2',
|
2018-09-19 13:54:49 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-04-15 01:41:17 +00:00
|
|
|
before do
|
2018-09-19 13:54:49 +00:00
|
|
|
Cti::Log.destroy_all
|
|
|
|
|
|
|
|
Setting.set('cti_integration', true)
|
|
|
|
Setting.set('cti_config', {
|
|
|
|
outbound: {
|
2018-12-19 17:31:51 +00:00
|
|
|
routing_table: [
|
2018-09-19 13:54:49 +00:00
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
dest: '41*',
|
2018-09-19 13:54:49 +00:00
|
|
|
caller_id: '41715880339000',
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
dest: '491714000000',
|
2018-09-19 13:54:49 +00:00
|
|
|
caller_id: '41715880339000',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default_caller_id: '4930777000000',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
inbound: {
|
2018-09-19 13:54:49 +00:00
|
|
|
block_caller_ids: [
|
|
|
|
{
|
|
|
|
caller_id: '491715000000',
|
2018-12-19 17:31:51 +00:00
|
|
|
note: 'some note',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
Cti::CallerId.rebuild
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'request handling' do
|
2019-07-09 22:07:32 +00:00
|
|
|
let!(:token) { Setting.get('cti_token') }
|
2018-09-19 13:54:49 +00:00
|
|
|
|
|
|
|
it 'does token check' do
|
2019-07-09 22:07:32 +00:00
|
|
|
post '/api/v1/cti/not_existing_token', params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
from: '4912347114711',
|
|
|
|
to: '4930600000000',
|
|
|
|
call_id: '4991155921769858278-1',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:unauthorized)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['error']).to eq('Invalid token, please contact your admin!')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does basic call' do
|
|
|
|
|
|
|
|
# inbound - I
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
from: '4912347114711',
|
|
|
|
to: '4930600000000',
|
|
|
|
call_id: '4991155921769858278-1',
|
|
|
|
user: ['user+1', 'user+2'],
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response).to be_blank
|
|
|
|
|
|
|
|
# inbound - II - block caller
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
from: '491715000000',
|
|
|
|
to: '4930600000000',
|
|
|
|
call_id: '4991155921769858278-2',
|
|
|
|
user: ['user+1', 'user+2'],
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['action']).to eq('reject')
|
|
|
|
expect(json_response['reason']).to eq('busy')
|
|
|
|
|
|
|
|
# outbound - I - set default_caller_id
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '8621106404543334274-3',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['action']).to eq('dial')
|
|
|
|
expect(json_response['number']).to eq('4912347114711')
|
|
|
|
expect(json_response['caller_id']).to eq('4930777000000')
|
|
|
|
|
|
|
|
# outbound - II - set caller_id based on routing_table by explicite number
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '491714000000',
|
|
|
|
call_id: '8621106404543334274-4',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['action']).to eq('dial')
|
|
|
|
expect(json_response['number']).to eq('491714000000')
|
|
|
|
expect(json_response['caller_id']).to eq('41715880339000')
|
|
|
|
|
|
|
|
# outbound - III - set caller_id based on routing_table by 41*
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4147110000000',
|
|
|
|
call_id: '8621106404543334274-5',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['action']).to eq('dial')
|
|
|
|
expect(json_response['number']).to eq('4147110000000')
|
|
|
|
expect(json_response['caller_id']).to eq('41715880339000')
|
|
|
|
|
|
|
|
# no config
|
|
|
|
Setting.set('cti_config', {})
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
from: '4912347114711',
|
|
|
|
to: '4930600000000',
|
|
|
|
call_id: '4991155921769858278-6',
|
|
|
|
user: ['user+1', 'user+2'],
|
|
|
|
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:unprocessable_entity)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['error']).to eq('Feature not configured, please contact your admin!')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does log call' do
|
|
|
|
|
|
|
|
# outbound - I - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-1',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.from).to eq('4930777000000')
|
|
|
|
expect(log.to).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('out')
|
|
|
|
expect(log.from_comment).to eq('user 1')
|
|
|
|
expect(log.to_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930777000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2018-10-18 09:42:37 +00:00
|
|
|
travel 2.seconds
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# outbound - I - hangup by agent
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'hangup',
|
|
|
|
direction: 'out',
|
|
|
|
call_id: '1234567890-1',
|
|
|
|
cause: 'cancel',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.from).to eq('4930777000000')
|
|
|
|
expect(log.to).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('out')
|
|
|
|
expect(log.from_comment).to eq('user 1')
|
|
|
|
expect(log.to_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to eq('cancel')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930777000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('hangup')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_truthy
|
2018-11-01 07:18:50 +00:00
|
|
|
expect(log.duration_waiting_time).to be_between(2, 3)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
|
|
|
# outbound - II - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
user: ['user 1'],
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.from).to eq('4930777000000')
|
|
|
|
expect(log.to).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('out')
|
|
|
|
expect(log.from_comment).to eq('user 1')
|
|
|
|
expect(log.to_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930777000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2018-10-18 09:42:37 +00:00
|
|
|
travel 2.seconds
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# outbound - II - answer by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'answer',
|
|
|
|
direction: 'out',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.from).to eq('4930777000000')
|
|
|
|
expect(log.to).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('out')
|
|
|
|
expect(log.from_comment).to eq('user 1')
|
|
|
|
expect(log.to_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930777000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('answer')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_nil
|
2018-11-01 07:18:50 +00:00
|
|
|
expect(log.duration_waiting_time).to be_between(2, 3)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2018-10-18 09:42:37 +00:00
|
|
|
travel 2.seconds
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# outbound - II - hangup by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'hangup',
|
|
|
|
direction: 'out',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
cause: 'normalClearing',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.from).to eq('4930777000000')
|
|
|
|
expect(log.to).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('out')
|
|
|
|
expect(log.from_comment).to eq('user 1')
|
|
|
|
expect(log.to_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to eq('normalClearing')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930777000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('hangup')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_truthy
|
2018-11-01 07:18:50 +00:00
|
|
|
expect(log.duration_waiting_time).to be_between(2, 3)
|
|
|
|
expect(log.duration_talking_time).to be_between(2, 3)
|
2018-09-19 13:54:49 +00:00
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - I - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
call_id: '1234567890-3',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - I - answer by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'answer',
|
|
|
|
direction: 'in',
|
|
|
|
call_id: '1234567890-3',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('answer')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_truthy
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - I - hangup by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'hangup',
|
|
|
|
direction: 'in',
|
|
|
|
call_id: '1234567890-3',
|
|
|
|
cause: 'normalClearing',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to eq('normalClearing')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('hangup')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_truthy
|
|
|
|
expect(log.duration_waiting_time).to be_truthy
|
|
|
|
expect(log.duration_talking_time).to be_truthy
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - II - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
call_id: '1234567890-4',
|
|
|
|
user: ['user 1', 'user 2'],
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.to_comment).to eq('user 1, user 2')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - II - answer by voicemail
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'answer',
|
|
|
|
direction: 'in',
|
|
|
|
call_id: '1234567890-4',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
user: 'voicemail',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('voicemail')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('answer')
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_truthy
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - II - hangup by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'hangup',
|
|
|
|
direction: 'in',
|
|
|
|
call_id: '1234567890-4',
|
|
|
|
cause: 'normalClearing',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('voicemail')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to eq('normalClearing')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('hangup')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_truthy
|
|
|
|
expect(log.end_at).to be_truthy
|
|
|
|
expect(log.duration_waiting_time).to be_truthy
|
|
|
|
expect(log.duration_talking_time).to be_truthy
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - III - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
call_id: '1234567890-5',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1,user 2')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - III - hangup by customer
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'hangup',
|
|
|
|
direction: 'in',
|
|
|
|
call_id: '1234567890-5',
|
|
|
|
cause: 'normalClearing',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('4912347114711')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1,user 2')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer1')
|
|
|
|
expect(log.comment).to eq('normalClearing')
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('hangup')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_truthy
|
|
|
|
expect(log.duration_waiting_time).to be_truthy
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - IV - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '49999992222222',
|
|
|
|
call_id: '1234567890-6',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-6')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('49999992222222')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1,user 2')
|
|
|
|
expect(log.from_comment).to eq('CallerId Customer3,CallerId Customer2')
|
|
|
|
expect(log.preferences['to']).to be_falsey
|
|
|
|
expect(log.preferences['from']).to be_truthy
|
|
|
|
expect(log.comment).to be_nil
|
2019-07-09 22:07:32 +00:00
|
|
|
expect(log.queue).to eq('4930600000000')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
2019-04-07 15:23:03 +00:00
|
|
|
travel 1.second
|
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
# inbound - IV - new call
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: 'anonymous',
|
|
|
|
call_id: '1234567890-7',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
queue: 'some_queue_name',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-7')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('anonymous')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1,user 2')
|
|
|
|
expect(log.from_comment).to be_nil
|
|
|
|
expect(log.preferences['to']).to be_falsey
|
|
|
|
expect(log.preferences['from']).to be_falsey
|
|
|
|
expect(log.comment).to be_nil
|
2018-10-16 14:35:31 +00:00
|
|
|
expect(log.queue).to eq('some_queue_name')
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
|
|
|
get '/api/v1/cti/log'
|
2021-02-04 08:28:41 +00:00
|
|
|
expect(response).to have_http_status(:forbidden)
|
2018-09-19 13:54:49 +00:00
|
|
|
|
2019-07-09 22:07:32 +00:00
|
|
|
# get caller list
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(agent)
|
2018-09-19 13:54:49 +00:00
|
|
|
get '/api/v1/cti/log', as: :json
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response['list']).to be_a_kind_of(Array)
|
|
|
|
expect(json_response['list'].count).to eq(7)
|
|
|
|
expect(json_response['assets']).to be_truthy
|
|
|
|
expect(json_response['assets']['User']).to be_truthy
|
2020-06-19 09:17:18 +00:00
|
|
|
expect(json_response['assets']['User'][customer2.id.to_s]).to be_truthy
|
|
|
|
expect(json_response['assets']['User'][customer3.id.to_s]).to be_truthy
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response['list'][0]['call_id']).to eq('1234567890-7')
|
|
|
|
expect(json_response['list'][1]['call_id']).to eq('1234567890-6')
|
|
|
|
expect(json_response['list'][2]['call_id']).to eq('1234567890-5')
|
|
|
|
expect(json_response['list'][3]['call_id']).to eq('1234567890-4')
|
|
|
|
expect(json_response['list'][4]['call_id']).to eq('1234567890-3')
|
|
|
|
expect(json_response['list'][5]['call_id']).to eq('1234567890-2')
|
|
|
|
expect(json_response['list'][5]['state']).to eq('hangup')
|
|
|
|
expect(json_response['list'][5]['from']).to eq('4930777000000')
|
|
|
|
expect(json_response['list'][5]['from_comment']).to eq('user 1')
|
|
|
|
expect(json_response['list'][5]['to']).to eq('4912347114711')
|
|
|
|
expect(json_response['list'][5]['to_comment']).to eq('CallerId Customer1')
|
|
|
|
expect(json_response['list'][5]['comment']).to eq('normalClearing')
|
|
|
|
expect(json_response['list'][5]['state']).to eq('hangup')
|
|
|
|
expect(json_response['list'][6]['call_id']).to eq('1234567890-1')
|
|
|
|
end
|
2018-10-18 09:42:37 +00:00
|
|
|
|
2019-07-09 22:07:32 +00:00
|
|
|
it 'does log call with notify group with two a log entry' do
|
|
|
|
|
|
|
|
# outbound - I - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-1',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
# outbound - II - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
|
|
|
|
|
|
|
# inbound - III - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
call_id: '1234567890-5',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
}
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
# get caller list (with notify group with 2 log entries)
|
|
|
|
cti_config = Setting.get('cti_config')
|
2020-06-19 09:17:18 +00:00
|
|
|
cti_config[:notify_map] = [{ queue: '4930777000000', user_ids: [agent.id.to_s] }]
|
2019-07-09 22:07:32 +00:00
|
|
|
Setting.set('cti_config', cti_config)
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(agent)
|
2019-07-09 22:07:32 +00:00
|
|
|
get '/api/v1/cti/log', as: :json
|
|
|
|
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
expect(json_response.dig('assets', 'User')).not_to be(nil)
|
|
|
|
expect(json_response['list'].map { |x| x['call_id'] }).to match_array(%w[1234567890-1 1234567890-2])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does log call with notify group without a log entry' do
|
|
|
|
|
|
|
|
# outbound - I - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-1',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
# outbound - II - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'out',
|
|
|
|
from: '4930600000000',
|
|
|
|
to: '4912347114711',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
user: 'user 1',
|
|
|
|
}
|
|
|
|
|
|
|
|
# inbound - III - new call
|
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: '4912347114711',
|
|
|
|
call_id: '1234567890-5',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
}
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
# get caller list (with notify group without a log entry)
|
|
|
|
cti_config = Setting.get('cti_config')
|
2020-06-19 09:17:18 +00:00
|
|
|
cti_config[:notify_map] = [{ queue: '4912347114711', user_ids: [agent.to_s] }]
|
2019-07-09 22:07:32 +00:00
|
|
|
Setting.set('cti_config', cti_config)
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(agent)
|
2019-07-09 22:07:32 +00:00
|
|
|
get '/api/v1/cti/log', as: :json
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
expect(json_response['list']).to eq([])
|
|
|
|
end
|
|
|
|
|
2018-10-18 09:42:37 +00:00
|
|
|
it 'does queue param tests' do
|
|
|
|
|
|
|
|
# inbound - queue & user
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: 'anonymous',
|
|
|
|
call_id: '1234567890-1',
|
|
|
|
user: 'user 1,user 2',
|
|
|
|
queue: 'some_queue_name',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-10-18 09:42:37 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('anonymous')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('user 1,user 2')
|
|
|
|
expect(log.from_comment).to be_nil
|
|
|
|
expect(log.preferences['to']).to be_falsey
|
|
|
|
expect(log.preferences['from']).to be_falsey
|
|
|
|
expect(log.comment).to be_nil
|
|
|
|
expect(log.queue).to eq('some_queue_name')
|
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
|
|
|
# inbound - queue & no user
|
2019-07-09 22:07:32 +00:00
|
|
|
post "/api/v1/cti/#{token}", params: {
|
|
|
|
event: 'newCall',
|
|
|
|
direction: 'in',
|
|
|
|
to: '4930600000000',
|
|
|
|
from: 'anonymous',
|
|
|
|
call_id: '1234567890-2',
|
|
|
|
user: '',
|
|
|
|
queue: 'some_queue_name',
|
|
|
|
}
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-10-18 09:42:37 +00:00
|
|
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
|
|
|
expect(log).to be_truthy
|
|
|
|
expect(log.to).to eq('4930600000000')
|
|
|
|
expect(log.from).to eq('anonymous')
|
|
|
|
expect(log.direction).to eq('in')
|
|
|
|
expect(log.to_comment).to eq('some_queue_name')
|
|
|
|
expect(log.from_comment).to be_nil
|
|
|
|
expect(log.preferences['to']).to be_falsey
|
|
|
|
expect(log.preferences['from']).to be_falsey
|
|
|
|
expect(log.comment).to be_nil
|
|
|
|
expect(log.queue).to eq('some_queue_name')
|
|
|
|
expect(log.state).to eq('newCall')
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
expect(log.initialized_at).to be_truthy
|
|
|
|
expect(log.start_at).to be_nil
|
|
|
|
expect(log.end_at).to be_nil
|
|
|
|
expect(log.duration_waiting_time).to be_nil
|
|
|
|
expect(log.duration_talking_time).to be_nil
|
|
|
|
|
|
|
|
end
|
2019-08-16 22:24:50 +00:00
|
|
|
|
|
|
|
it 'flags caller_log as done' do
|
|
|
|
|
|
|
|
cti_log1 = create(:cti_log)
|
|
|
|
log = Cti::Log.find(cti_log1.id)
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(agent)
|
2019-08-16 22:24:50 +00:00
|
|
|
post "/api/v1/cti/done/#{cti_log1.id}", params: {
|
|
|
|
done: true
|
|
|
|
}
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
|
|
|
|
log = Cti::Log.find(cti_log1.id)
|
|
|
|
expect(log.done).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'flags all caller_logs as done via done_bulk' do
|
|
|
|
|
|
|
|
cti_log1 = create(:cti_log)
|
|
|
|
cti_log2 = create(:cti_log)
|
|
|
|
|
|
|
|
log = Cti::Log.find(cti_log1.id)
|
|
|
|
expect(log.done).to eq(false)
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(agent)
|
2019-08-16 22:24:50 +00:00
|
|
|
post '/api/v1/cti/done/bulk', params: {
|
|
|
|
ids: [cti_log1.id, cti_log2.id]
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
|
log1 = Cti::Log.find(cti_log1.id)
|
|
|
|
expect(log1.done).to eq(true)
|
|
|
|
|
|
|
|
log2 = Cti::Log.find(cti_log2.id)
|
|
|
|
expect(log2.done).to eq(true)
|
|
|
|
end
|
2018-09-19 13:54:49 +00:00
|
|
|
end
|
|
|
|
end
|