Improved test.

This commit is contained in:
Martin Edenhofer 2018-10-16 16:35:31 +02:00
parent 0cca58f0b7
commit d0bafea5e7
2 changed files with 26 additions and 8 deletions

View file

@ -280,13 +280,14 @@ returns
processes a incoming event
Cti::Log.process(
'cause' => '',
'event' => 'newCall',
'user' => 'user 1',
'from' => '4912347114711',
'to' => '4930600000000',
'callId' => '43545211', # or call_id
'direction' => 'in',
cause: '',
event: 'newCall',
user: 'user 1',
from: '4912347114711',
to: '4930600000000',
callId: '43545211', # or call_id
direction: 'in',
queue: 'helpdesk', # optional
)
=end
@ -295,6 +296,7 @@ Cti::Log.process(
cause = params['cause']
event = params['event']
user = params['user']
queue = params['queue']
call_id = params['callId'] || params['call_id']
if user.class == Array
user = user.join(', ')
@ -329,6 +331,7 @@ Cti::Log.process(
to_comment: to_comment,
call_id: call_id,
comment: cause,
queue: queue,
state: event,
initialized_at: Time.zone.now,
preferences: preferences,

View file

@ -153,6 +153,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.from_comment).to eq('user 1')
expect(log.to_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -173,6 +174,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.from_comment).to eq('user 1')
expect(log.to_comment).to eq('CallerId Customer1')
expect(log.comment).to eq('cancel')
expect(log.queue).to be_nil
expect(log.state).to eq('hangup')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -193,6 +195,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.from_comment).to eq('user 1')
expect(log.to_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -213,6 +216,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.from_comment).to eq('user 1')
expect(log.to_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('answer')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -233,6 +237,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.from_comment).to eq('user 1')
expect(log.to_comment).to eq('CallerId Customer1')
expect(log.comment).to eq('normalClearing')
expect(log.queue).to be_nil
expect(log.state).to eq('hangup')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -253,6 +258,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -273,6 +279,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('answer')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -293,6 +300,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to eq('normalClearing')
expect(log.queue).to be_nil
expect(log.state).to eq('hangup')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -313,6 +321,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1,user 2')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -333,6 +342,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('voicemail')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('answer')
expect(log.done).to eq(true)
expect(log.initialized_at).to be_truthy
@ -353,6 +363,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('voicemail')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to eq('normalClearing')
expect(log.queue).to be_nil
expect(log.state).to eq('hangup')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -373,6 +384,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1,user 2')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -393,6 +405,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.to_comment).to eq('user 1,user 2')
expect(log.from_comment).to eq('CallerId Customer1')
expect(log.comment).to eq('normalClearing')
expect(log.queue).to be_nil
expect(log.state).to eq('hangup')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -415,6 +428,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.preferences['to']).to be_falsey
expect(log.preferences['from']).to be_truthy
expect(log.comment).to be_nil
expect(log.queue).to be_nil
expect(log.state).to eq('newCall')
expect(log.done).to eq(false)
expect(log.initialized_at).to be_truthy
@ -424,7 +438,7 @@ RSpec.describe 'Integration CTI', type: :request do
expect(log.duration_talking_time).to be_nil
# inbound - IV - new call
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-7&user%5B%5D=user+1,user+2'
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-7&user%5B%5D=user+1,user+2&queue=some_queue_name'
post "/api/v1/cti/#{token}", params: params
expect(response).to have_http_status(200)
log = Cti::Log.find_by(call_id: '1234567890-7')
@ -437,6 +451,7 @@ RSpec.describe 'Integration CTI', type: :request do
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