spec/punchblock/translator/asterisk_spec.rb in punchblock-1.4.0 vs spec/punchblock/translator/asterisk_spec.rb in punchblock-1.4.1
- old
+ new
@@ -581,9 +581,48 @@
subject.handle_ami_event ami_event
end
end
end
end
+
+ describe 'with an event for a channel with Bridge and special statuses appended' do
+ let :ami_event do
+ RubyAMI::Event.new('AGIExec').tap do |e|
+ e['SubEvent'] = "End"
+ e['Channel'] = "Bridge/SIP/1234-00000000<ZOMBIE>"
+ end
+ end
+
+ let :ami_event2 do
+ RubyAMI::Event.new('Hangup').tap do |e|
+ e['Uniqueid'] = "1320842458.8"
+ e['Calleridnum'] = "5678"
+ e['Calleridname'] = "Jane Smith"
+ e['Cause'] = "0"
+ e['Cause-txt'] = "Unknown"
+ e['Channel'] = "Bridge/SIP/1234-00000000<ZOMBIE>"
+ end
+ end
+
+ let(:call) do
+ 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"
+ end
+
+ before do
+ subject.register_call call
+ end
+
+ it 'sends the AMI event to the call and to the connection as a PB event if it is an allowed event' do
+ call.expects(:process_ami_event!).once.with ami_event
+ subject.handle_ami_event ami_event
+ end
+
+ it 'does not send the AMI event to a bridged channel if it is not allowed' do
+ call.expects(:process_ami_event!).never.with ami_event2
+ subject.handle_ami_event ami_event2
+ end
+
+ end
end#handle_ami_event
describe '#send_ami_action' do
it 'should send the action to the AMI client' do
ami_client.expects(:send_action).once.with 'foo', :foo => :bar