punchblock 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e22367a7afc3824dff77a61e77d6b0008208f7b
4
- data.tar.gz: b4b52ffd999987e0bb67a4a3da052f3b1547e4d3
3
+ metadata.gz: 60e6ce85c4eb99dac8e18f5b06f868e13562fa64
4
+ data.tar.gz: 70ce395958873bbb5078caf5bd9ba517015d4e35
5
5
  SHA512:
6
- metadata.gz: f212f2fcbba8b23ed7a88ac16dd8a9785cefaef44818f9d52c35d2155514169fae63ee797268482b0b79b68bf1e01a7c011f59baac6f444eb5f9cc122eced8c4
7
- data.tar.gz: 48846a2da3e64093ea3fef764ff5f33357f393496f13e70dd767c65fd6040b443fdb44b134b7ae02c9b2be25a2fcf538b71cd91d5e59b220f22c62b148748002
6
+ metadata.gz: deb55ad4aa2888d889f33b55c769d567b837849475fd594ba9e8a07b3628d43880ccb25ef8e9ea1d05889481b4c423b994ce15cad5fe015791baa3525b3f11a5
7
+ data.tar.gz: 758ccbfed733614dbede05e2dd94525103085c7b5a0b6cf5e0bccb6e89f024e93a802716ae862157c6d87dd3d9a5a97d18444fe0673b471ddfc1520598a42a3c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # [develop](https://github.com/adhearsion/punchblock)
2
2
 
3
+ # [v2.2.2](https://github.com/adhearsion/punchblock/compare/v2.2.1...v2.2.2) - [2014-01-21](https://rubygems.org/gems/punchblock/versions/2.2.2)
4
+ * Bugfix: Delay sending Answered event on call until AsyncAGI is invoked
5
+
3
6
  # [v2.2.1](https://github.com/adhearsion/punchblock/compare/v2.2.0...v2.2.1) - [2014-01-17](https://rubygems.org/gems/punchblock/versions/2.2.1)
4
7
  * Bugfix: `Punchblock::Event::Complete::Reason` is now a `Punchblock::Event`
5
8
 
@@ -118,13 +118,15 @@ module Punchblock
118
118
  if component = component_with_id(ami_event['CommandID'])
119
119
  component.handle_ami_event ami_event
120
120
  end
121
+
122
+ if @answered == false && ami_event['SubEvent'] == 'Start'
123
+ @answered = true
124
+ send_pb_event Event::Answered.new
125
+ end
121
126
  when 'Newstate'
122
127
  case ami_event['ChannelState']
123
128
  when '5'
124
129
  send_pb_event Event::Ringing.new
125
- when '6'
126
- @answered = true
127
- send_pb_event Event::Answered.new
128
130
  end
129
131
  when 'OriginateResponse'
130
132
  if ami_event['Response'] == 'Failure' && ami_event['Uniqueid'] == '<null>'
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Punchblock
4
- VERSION = "2.2.1"
4
+ VERSION = "2.2.2"
5
5
  end
@@ -498,6 +498,42 @@ module Punchblock
498
498
  component.should_receive(:handle_ami_event).once.with ami_event
499
499
  subject.process_ami_event ami_event
500
500
  end
501
+
502
+ it 'should not send an answered event' do
503
+ translator.should_receive(:handle_pb_event).with(kind_of(Punchblock::Event::Answered)).never
504
+ subject.process_ami_event ami_event
505
+ end
506
+ end
507
+
508
+ context 'with an AsyncAGI Start event' do
509
+ let(:ami_event) do
510
+ RubyAMI::Event.new "AsyncAGI",
511
+ "SubEvent" => "Start",
512
+ "Channel" => "SIP/1234-00000000",
513
+ "Env" => "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2Fuserb-00000006%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201390303636.6%0Aagi_version%3A%2011.7.0%0Aagi_callerid%3A%20userb%0Aagi_calleridname%3A%20User%20B%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%20unknown%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20adhearsion-redirect%0Aagi_extension%3A%201%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%20139696536876800%0A%0A"
514
+ end
515
+
516
+ it 'should send an answered event' do
517
+ expected_answered = Punchblock::Event::Answered.new
518
+ expected_answered.target_call_id = subject.id
519
+ translator.should_receive(:handle_pb_event).with expected_answered
520
+ subject.process_ami_event ami_event
521
+ end
522
+
523
+ it '#answered? should be true' do
524
+ subject.process_ami_event ami_event
525
+ subject.answered?.should be_true
526
+ end
527
+
528
+ context "for a second time" do
529
+ it 'should only send one answered event' do
530
+ expected_answered = Punchblock::Event::Answered.new
531
+ expected_answered.target_call_id = subject.id
532
+ translator.should_receive(:handle_pb_event).with(expected_answered).once
533
+ subject.process_ami_event ami_event
534
+ subject.process_ami_event ami_event
535
+ end
536
+ end
501
537
  end
502
538
 
503
539
  context 'with a Newstate event' do
@@ -530,23 +566,6 @@ module Punchblock
530
566
  subject.answered?.should be_false
531
567
  end
532
568
  end
533
-
534
- context 'up' do
535
- let(:channel_state) { '6' }
536
- let(:channel_state_desc) { 'Up' }
537
-
538
- it 'should send a ringing event' do
539
- expected_answered = Punchblock::Event::Answered.new
540
- expected_answered.target_call_id = subject.id
541
- translator.should_receive(:handle_pb_event).with expected_answered
542
- subject.process_ami_event ami_event
543
- end
544
-
545
- it '#answered? should be true' do
546
- subject.process_ami_event ami_event
547
- subject.answered?.should be_true
548
- end
549
- end
550
569
  end
551
570
 
552
571
  context 'with an OriginateResponse event' do
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: 2.2.1
4
+ version: 2.2.2
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: 2014-01-17 00:00:00.000000000 Z
13
+ date: 2014-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri