punchblock 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/lib/punchblock/component/asterisk/agi/command.rb +0 -11
- data/lib/punchblock/connection/asterisk.rb +3 -3
- data/lib/punchblock/translator/asterisk/agi_command.rb +40 -0
- data/lib/punchblock/translator/asterisk/call.rb +56 -47
- data/lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb +13 -37
- data/lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb +24 -41
- data/lib/punchblock/translator/asterisk/component/input.rb +2 -1
- data/lib/punchblock/translator/asterisk/component/output.rb +16 -21
- data/lib/punchblock/translator/asterisk/component/record.rb +11 -19
- data/lib/punchblock/translator/asterisk/component.rb +12 -9
- data/lib/punchblock/translator/asterisk.rb +16 -22
- data/lib/punchblock/translator/dtmf_recognizer.rb +4 -4
- data/lib/punchblock/translator/freeswitch/component/input.rb +2 -1
- data/lib/punchblock/translator/input_component.rb +2 -2
- data/lib/punchblock/version.rb +1 -1
- data/punchblock.gemspec +1 -1
- data/spec/punchblock/connection/asterisk_spec.rb +8 -7
- data/spec/punchblock/translator/asterisk/call_spec.rb +262 -229
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +57 -29
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +40 -46
- data/spec/punchblock/translator/asterisk/component/input_spec.rb +7 -7
- data/spec/punchblock/translator/asterisk/component/output_spec.rb +84 -53
- data/spec/punchblock/translator/asterisk/component/record_spec.rb +55 -83
- data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +5 -1
- data/spec/punchblock/translator/asterisk/component_spec.rb +2 -10
- data/spec/punchblock/translator/asterisk_spec.rb +73 -100
- metadata +5 -10
|
@@ -7,7 +7,7 @@ module Punchblock
|
|
|
7
7
|
module Translator
|
|
8
8
|
describe Asterisk do
|
|
9
9
|
let(:ami_client) { mock 'RubyAMI::Client' }
|
|
10
|
-
let(:connection) { mock 'Connection::Asterisk' }
|
|
10
|
+
let(:connection) { mock 'Connection::Asterisk', handle_event: nil }
|
|
11
11
|
let(:media_engine) { :asterisk }
|
|
12
12
|
|
|
13
13
|
let(:translator) { Asterisk.new ami_client, connection, media_engine }
|
|
@@ -31,7 +31,7 @@ module Punchblock
|
|
|
31
31
|
|
|
32
32
|
describe '#shutdown' do
|
|
33
33
|
it "instructs all calls to shutdown" do
|
|
34
|
-
call = Asterisk::Call.new 'foo', subject
|
|
34
|
+
call = Asterisk::Call.new 'foo', subject, ami_client, connection
|
|
35
35
|
call.async.should_receive(:shutdown).once
|
|
36
36
|
subject.register_call call
|
|
37
37
|
subject.shutdown
|
|
@@ -84,7 +84,7 @@ module Punchblock
|
|
|
84
84
|
describe '#register_call' do
|
|
85
85
|
let(:call_id) { 'abc123' }
|
|
86
86
|
let(:channel) { 'SIP/foo' }
|
|
87
|
-
let(:call) { Translator::Asterisk::Call.new channel, subject }
|
|
87
|
+
let(:call) { Translator::Asterisk::Call.new channel, subject, ami_client, connection }
|
|
88
88
|
|
|
89
89
|
before do
|
|
90
90
|
call.stub(:id).and_return call_id
|
|
@@ -103,7 +103,7 @@ module Punchblock
|
|
|
103
103
|
describe '#deregister_call' do
|
|
104
104
|
let(:call_id) { 'abc123' }
|
|
105
105
|
let(:channel) { 'SIP/foo' }
|
|
106
|
-
let(:call) { Translator::Asterisk::Call.new channel, subject }
|
|
106
|
+
let(:call) { Translator::Asterisk::Call.new channel, subject, ami_client, connection }
|
|
107
107
|
|
|
108
108
|
before do
|
|
109
109
|
call.stub(:id).and_return call_id
|
|
@@ -138,7 +138,7 @@ module Punchblock
|
|
|
138
138
|
let(:command) { Command::Answer.new.tap { |c| c.target_call_id = call_id } }
|
|
139
139
|
|
|
140
140
|
context "with a known call ID" do
|
|
141
|
-
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
|
|
141
|
+
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject, ami_client, connection }
|
|
142
142
|
|
|
143
143
|
before do
|
|
144
144
|
command.request!
|
|
@@ -165,8 +165,8 @@ module Punchblock
|
|
|
165
165
|
let(:call_id) { dial_command.response.id }
|
|
166
166
|
|
|
167
167
|
before do
|
|
168
|
+
subject.async.should_receive(:execute_global_command)
|
|
168
169
|
subject.execute_command dial_command
|
|
169
|
-
ami_client.as_null_object
|
|
170
170
|
end
|
|
171
171
|
|
|
172
172
|
it 'sends an error in response to the command' do
|
|
@@ -191,11 +191,10 @@ module Punchblock
|
|
|
191
191
|
|
|
192
192
|
context "for an incoming call which began executing but crashed" do
|
|
193
193
|
let :ami_event do
|
|
194
|
-
RubyAMI::Event.new
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
end
|
|
194
|
+
RubyAMI::Event.new 'AsyncAGI',
|
|
195
|
+
'SubEvent' => "Start",
|
|
196
|
+
'Channel' => "SIP/1234-00000000",
|
|
197
|
+
'Env' => "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
199
198
|
end
|
|
200
199
|
|
|
201
200
|
let(:call) { subject.call_for_channel('SIP/1234-00000000') }
|
|
@@ -235,7 +234,7 @@ module Punchblock
|
|
|
235
234
|
end
|
|
236
235
|
|
|
237
236
|
describe '#execute_component_command' do
|
|
238
|
-
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
|
|
237
|
+
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject, ami_client, connection }
|
|
239
238
|
let(:component_node) { Component::Output.new }
|
|
240
239
|
let(:component) { Translator::Asterisk::Component::Output.new(component_node, call) }
|
|
241
240
|
|
|
@@ -272,7 +271,7 @@ module Punchblock
|
|
|
272
271
|
|
|
273
272
|
before do
|
|
274
273
|
command.request!
|
|
275
|
-
ami_client.
|
|
274
|
+
ami_client.stub(:send_action).and_return RubyAMI::Response.new
|
|
276
275
|
end
|
|
277
276
|
|
|
278
277
|
it 'should be able to look up the call by channel ID' do
|
|
@@ -297,13 +296,13 @@ module Punchblock
|
|
|
297
296
|
let(:mock_action) { stub('Asterisk::Component::Asterisk::AMIAction').as_null_object }
|
|
298
297
|
|
|
299
298
|
it 'should create a component actor and execute it asynchronously' do
|
|
300
|
-
Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject).and_return mock_action
|
|
299
|
+
Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject, ami_client).and_return mock_action
|
|
301
300
|
mock_action.async.should_receive(:execute).once
|
|
302
301
|
subject.execute_global_command command
|
|
303
302
|
end
|
|
304
303
|
|
|
305
304
|
it 'registers the component' do
|
|
306
|
-
Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject).and_return mock_action
|
|
305
|
+
Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject, ami_client).and_return mock_action
|
|
307
306
|
subject.wrapped_object.should_receive(:register_component).with mock_action
|
|
308
307
|
subject.execute_global_command command
|
|
309
308
|
end
|
|
@@ -331,12 +330,11 @@ module Punchblock
|
|
|
331
330
|
|
|
332
331
|
describe '#handle_ami_event' do
|
|
333
332
|
let :ami_event do
|
|
334
|
-
RubyAMI::Event.new
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
end
|
|
333
|
+
RubyAMI::Event.new 'Newchannel',
|
|
334
|
+
'Channel' => "SIP/101-3f3f",
|
|
335
|
+
'State' => "Ring",
|
|
336
|
+
'Callerid' => "101",
|
|
337
|
+
'Uniqueid' => "1094154427.10"
|
|
340
338
|
end
|
|
341
339
|
|
|
342
340
|
let :expected_pb_event do
|
|
@@ -362,30 +360,19 @@ module Punchblock
|
|
|
362
360
|
describe 'with a FullyBooted event' do
|
|
363
361
|
let(:ami_event) { RubyAMI::Event.new 'FullyBooted' }
|
|
364
362
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
end
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
context 'twice' do
|
|
373
|
-
it 'sends a connected event to the event handler' do
|
|
374
|
-
subject.connection.should_receive(:handle_event).once.with Connection::Connected.new
|
|
375
|
-
subject.wrapped_object.should_receive(:run_at_fully_booted).once
|
|
376
|
-
subject.handle_ami_event ami_event
|
|
377
|
-
subject.handle_ami_event ami_event
|
|
378
|
-
end
|
|
363
|
+
it 'sends a connected event to the event handler' do
|
|
364
|
+
subject.connection.should_receive(:handle_event).once.with Connection::Connected.new
|
|
365
|
+
subject.wrapped_object.should_receive(:run_at_fully_booted).once
|
|
366
|
+
subject.handle_ami_event ami_event
|
|
379
367
|
end
|
|
380
368
|
end
|
|
381
369
|
|
|
382
370
|
describe 'with an AsyncAGI Start event' do
|
|
383
371
|
let :ami_event do
|
|
384
|
-
RubyAMI::Event.new
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
end
|
|
372
|
+
RubyAMI::Event.new 'AsyncAGI',
|
|
373
|
+
'SubEvent' => "Start",
|
|
374
|
+
'Channel' => "SIP/1234-00000000",
|
|
375
|
+
'Env' => "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
389
376
|
end
|
|
390
377
|
|
|
391
378
|
before { subject.wrapped_object.stub :handle_pb_event }
|
|
@@ -428,7 +415,7 @@ module Punchblock
|
|
|
428
415
|
end
|
|
429
416
|
|
|
430
417
|
context 'if a call already exists for a matching channel' do
|
|
431
|
-
let(:call) { Asterisk::Call.new "SIP/1234-00000000", subject }
|
|
418
|
+
let(:call) { Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection }
|
|
432
419
|
|
|
433
420
|
before do
|
|
434
421
|
subject.register_call call
|
|
@@ -442,11 +429,10 @@ module Punchblock
|
|
|
442
429
|
|
|
443
430
|
context "for a 'h' extension" do
|
|
444
431
|
let :ami_event do
|
|
445
|
-
RubyAMI::Event.new
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
end
|
|
432
|
+
RubyAMI::Event.new 'AsyncAGI',
|
|
433
|
+
'SubEvent' => "Start",
|
|
434
|
+
'Channel' => "SIP/1234-00000000",
|
|
435
|
+
'Env' => "agi_extension%3A%20h%0A%0A"
|
|
450
436
|
end
|
|
451
437
|
|
|
452
438
|
it "should not create a new call" do
|
|
@@ -462,11 +448,10 @@ module Punchblock
|
|
|
462
448
|
|
|
463
449
|
context "for a 'Kill' type" do
|
|
464
450
|
let :ami_event do
|
|
465
|
-
RubyAMI::Event.new
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
end
|
|
451
|
+
RubyAMI::Event.new 'AsyncAGI',
|
|
452
|
+
'SubEvent' => "Start",
|
|
453
|
+
'Channel' => "SIP/1234-00000000",
|
|
454
|
+
'Env' => "agi_type%3A%20Kill%0A%0A"
|
|
470
455
|
end
|
|
471
456
|
|
|
472
457
|
it "should not create a new call" do
|
|
@@ -483,13 +468,12 @@ module Punchblock
|
|
|
483
468
|
|
|
484
469
|
describe 'with a VarSet event including a punchblock_call_id' do
|
|
485
470
|
let :ami_event do
|
|
486
|
-
RubyAMI::Event.new
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
end
|
|
471
|
+
RubyAMI::Event.new 'VarSet',
|
|
472
|
+
"Privilege" => "dialplan,all",
|
|
473
|
+
"Channel" => "SIP/1234-00000000",
|
|
474
|
+
"Variable" => "punchblock_call_id",
|
|
475
|
+
"Value" => call_id,
|
|
476
|
+
"Uniqueid" => "1326210224.0"
|
|
493
477
|
end
|
|
494
478
|
|
|
495
479
|
before do
|
|
@@ -536,18 +520,17 @@ module Punchblock
|
|
|
536
520
|
|
|
537
521
|
describe 'with an AMI event for a known channel' do
|
|
538
522
|
let :ami_event do
|
|
539
|
-
RubyAMI::Event.new
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
end
|
|
523
|
+
RubyAMI::Event.new 'Hangup',
|
|
524
|
+
'Uniqueid' => "1320842458.8",
|
|
525
|
+
'Calleridnum' => "5678",
|
|
526
|
+
'Calleridname' => "Jane Smith",
|
|
527
|
+
'Cause' => "0",
|
|
528
|
+
'Cause-txt' => "Unknown",
|
|
529
|
+
'Channel' => "SIP/1234-00000000"
|
|
547
530
|
end
|
|
548
531
|
|
|
549
532
|
let(:call) do
|
|
550
|
-
Asterisk::Call.new "SIP/1234-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
533
|
+
Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
551
534
|
end
|
|
552
535
|
|
|
553
536
|
before do
|
|
@@ -561,17 +544,16 @@ module Punchblock
|
|
|
561
544
|
|
|
562
545
|
context 'with a Channel1 and Channel2 specified on the event' do
|
|
563
546
|
let :ami_event do
|
|
564
|
-
RubyAMI::Event.new
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
end
|
|
547
|
+
RubyAMI::Event.new 'BridgeAction',
|
|
548
|
+
'Privilege' => "call,all",
|
|
549
|
+
'Response' => "Success",
|
|
550
|
+
'Channel1' => "SIP/1234-00000000",
|
|
551
|
+
'Channel2' => "SIP/5678-00000000"
|
|
570
552
|
end
|
|
571
553
|
|
|
572
554
|
context 'with calls for those channels' do
|
|
573
555
|
let(:call2) do
|
|
574
|
-
Asterisk::Call.new "SIP/5678-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
556
|
+
Asterisk::Call.new "SIP/5678-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
575
557
|
end
|
|
576
558
|
|
|
577
559
|
before { subject.register_call call2 }
|
|
@@ -587,25 +569,23 @@ module Punchblock
|
|
|
587
569
|
|
|
588
570
|
describe 'with an event for a channel with Bridge and special statuses appended' do
|
|
589
571
|
let :ami_event do
|
|
590
|
-
RubyAMI::Event.new
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
end
|
|
572
|
+
RubyAMI::Event.new 'AGIExec',
|
|
573
|
+
'SubEvent' => "End",
|
|
574
|
+
'Channel' => "Bridge/SIP/1234-00000000<ZOMBIE>"
|
|
594
575
|
end
|
|
595
576
|
|
|
596
577
|
let :ami_event2 do
|
|
597
|
-
RubyAMI::Event.new
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
end
|
|
578
|
+
RubyAMI::Event.new 'Hangup',
|
|
579
|
+
'Uniqueid' => "1320842458.8",
|
|
580
|
+
'Calleridnum' => "5678",
|
|
581
|
+
'Calleridname' => "Jane Smith",
|
|
582
|
+
'Cause' => "0",
|
|
583
|
+
'Cause-txt' => "Unknown",
|
|
584
|
+
'Channel' => "Bridge/SIP/1234-00000000<ZOMBIE>"
|
|
605
585
|
end
|
|
606
586
|
|
|
607
587
|
let(:call) do
|
|
608
|
-
Asterisk::Call.new "SIP/1234-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
588
|
+
Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
|
|
609
589
|
end
|
|
610
590
|
|
|
611
591
|
before do
|
|
@@ -623,41 +603,34 @@ module Punchblock
|
|
|
623
603
|
end
|
|
624
604
|
|
|
625
605
|
end
|
|
626
|
-
end#handle_ami_event
|
|
627
|
-
|
|
628
|
-
describe '#send_ami_action' do
|
|
629
|
-
it 'should send the action to the AMI client' do
|
|
630
|
-
ami_client.should_receive(:send_action).once.with 'foo', :foo => :bar
|
|
631
|
-
subject.send_ami_action 'foo', :foo => :bar
|
|
632
|
-
end
|
|
633
606
|
end
|
|
634
607
|
|
|
635
608
|
describe '#run_at_fully_booted' do
|
|
636
609
|
let(:broken_path) { "/this/is/not/a/valid/path" }
|
|
637
610
|
|
|
638
611
|
let(:passed_show) do
|
|
639
|
-
OpenStruct.new
|
|
612
|
+
OpenStruct.new text_body: "[ Context 'adhearsion-redirect' created by 'pbx_config' ]\n '1' => 1. AGI(agi:async)[pbx_config]\n\n-= 1 extension (1 priority) in 1 context. =-"
|
|
640
613
|
end
|
|
641
614
|
|
|
642
615
|
let(:failed_show) do
|
|
643
|
-
OpenStruct.new
|
|
616
|
+
OpenStruct.new text_body: "There is no existence of 'adhearsion-redirect' context\nCommand 'dialplan show adhearsion-redirect' failed."
|
|
644
617
|
end
|
|
645
618
|
|
|
646
619
|
it 'should send the redirect extension Command to the AMI client' do
|
|
647
620
|
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
|
|
648
|
-
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}")
|
|
621
|
+
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
|
|
649
622
|
subject.run_at_fully_booted
|
|
650
623
|
end
|
|
651
624
|
|
|
652
625
|
it 'should check the context for existence and do nothing if it is there' do
|
|
653
626
|
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
|
|
654
|
-
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").
|
|
627
|
+
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
|
|
655
628
|
subject.run_at_fully_booted
|
|
656
629
|
end
|
|
657
630
|
|
|
658
631
|
it 'should check the context for existence and log an error if it is not there' do
|
|
659
632
|
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
|
|
660
|
-
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").
|
|
633
|
+
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(failed_show)
|
|
661
634
|
Punchblock.logger.should_receive(:error).once.with("Punchblock failed to add the #{Asterisk::REDIRECT_EXTENSION} extension to the #{Asterisk::REDIRECT_CONTEXT} context. Please add a [#{Asterisk::REDIRECT_CONTEXT}] entry to your dialplan.")
|
|
662
635
|
subject.run_at_fully_booted
|
|
663
636
|
end
|
|
@@ -665,7 +638,7 @@ module Punchblock
|
|
|
665
638
|
it 'should check the recording directory for existence' do
|
|
666
639
|
stub_const('Punchblock::Translator::Asterisk::Component::Record::RECORDING_BASE_PATH', broken_path)
|
|
667
640
|
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
|
|
668
|
-
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}")
|
|
641
|
+
ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
|
|
669
642
|
Punchblock.logger.should_receive(:warn).once.with("Recordings directory #{broken_path} does not exist. Recording might not work. This warning can be ignored if Adhearsion is running on a separate machine than Asterisk. See http://adhearsion.com/docs/call-controllers#recording")
|
|
670
643
|
subject.run_at_fully_booted
|
|
671
644
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: punchblock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jason Goecke
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2013-04
|
|
13
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: niceogiri
|
|
@@ -136,20 +136,14 @@ dependencies:
|
|
|
136
136
|
requirements:
|
|
137
137
|
- - ~>
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: '
|
|
140
|
-
- - '>='
|
|
141
|
-
- !ruby/object:Gem::Version
|
|
142
|
-
version: 1.2.1
|
|
139
|
+
version: '2.0'
|
|
143
140
|
type: :runtime
|
|
144
141
|
prerelease: false
|
|
145
142
|
version_requirements: !ruby/object:Gem::Requirement
|
|
146
143
|
requirements:
|
|
147
144
|
- - ~>
|
|
148
145
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '
|
|
150
|
-
- - '>='
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: 1.2.1
|
|
146
|
+
version: '2.0'
|
|
153
147
|
- !ruby/object:Gem::Dependency
|
|
154
148
|
name: ruby_fs
|
|
155
149
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -381,6 +375,7 @@ files:
|
|
|
381
375
|
- lib/punchblock/ref.rb
|
|
382
376
|
- lib/punchblock/translator.rb
|
|
383
377
|
- lib/punchblock/translator/asterisk.rb
|
|
378
|
+
- lib/punchblock/translator/asterisk/agi_command.rb
|
|
384
379
|
- lib/punchblock/translator/asterisk/call.rb
|
|
385
380
|
- lib/punchblock/translator/asterisk/component.rb
|
|
386
381
|
- lib/punchblock/translator/asterisk/component/asterisk.rb
|