diff --git a/lib/call_attempt_repo.rb b/lib/call_attempt_repo.rb index 89bfc6336a6e2e0636bd8cc424a65d08852abe9c..ab1a6b402f192d2475c1949718197fb5c2d7038c 100644 --- a/lib/call_attempt_repo.rb +++ b/lib/call_attempt_repo.rb @@ -46,9 +46,9 @@ class CallAttemptRepo end end - def ending_call(customer, call_id) + def ending_call(customer_id, call_id) redis.srem( - "jmp_customer_ongoing_calls-#{customer.customer_id}", + "jmp_customer_ongoing_calls-#{customer_id}", call_id ) end diff --git a/lib/cdr_repo.rb b/lib/cdr_repo.rb index 7f5db2dac3f0c2206b8060419a1ee98336b15995..a32a558385aca259087870ae1c77871e4070635c 100644 --- a/lib/cdr_repo.rb +++ b/lib/cdr_repo.rb @@ -12,7 +12,7 @@ class CDRRepo data.delete(:rate) data.delete(:charge) columns, values = data.to_a.transpose - DB.query_defer(<<~SQL, values) + @db.query_defer(<<~SQL, values) INSERT INTO cdr (#{columns.join(',')}) VALUES ($1, $2, $3, $4, $5, $6, $7) SQL diff --git a/test/test_helper.rb b/test/test_helper.rb index daedb15c953fae1839d3bc3fb4779534c9e7f79d..e87fc8ff6c99bfe9c600b81c7e5102d273369fb1 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -291,7 +291,7 @@ class FakeRedis end def srem(key, member) - @values[key].delete(member) + @values[key]&.delete(member) end def scard(key) diff --git a/test/test_web.rb b/test/test_web.rb index e334abf90ef4d3a73cbe6848da6c2bbacb0eafcd..6db0458377d07fbcd6e405959f36b47a6484eae8 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -127,6 +127,7 @@ class WebTest < Minitest::Test ) ) ) + Web.opts[:cdr_repo] = CDRRepo.new(db: FakeDB.new) Web.opts[:common_logger] = FakeLog.new Web.opts[:reachability_repo] = ReachabilityRepo::Voice.new( redis: ReachableRedis, @@ -359,6 +360,26 @@ class WebTest < Minitest::Test end em :test_outbound_toll_free + def test_outbound_disconnect + post( + "/outbound/calls/status", + { + eventType: "disconnect", + from: "ccustomerid", + to: "+15557654321", + callId: "acall", + startTime: Time.now.to_s, + endTime: Time.now.to_s, + cause: "hangup" + }.to_json, + { "CONTENT_TYPE" => "application/json" } + ) + + assert last_response.ok? + assert_equal("OK", last_response.body) + end + em :test_outbound_disconnect + def test_inbound CustomerFwd::BANDWIDTH_VOICE.expect( :create_call,