diff --git a/test/test_web.rb b/test/test_web.rb index 3cfe8280c8d0d02245d7e5450bb0a53dbf68141f..dc79046fe3a2e56b17095f07a980045dfbc3df50 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -558,4 +558,27 @@ class WebTest < Minitest::Test assert_mock Customer::BLATHER end em :test_voicemail_short + + def test_voicemail_no_customer + post( + "/inbound/calls/CALLID/voicemail", + { + "startTime" => "2021-01-01T00:00:00Z", + "endTime" => "2021-01-01T00:00:06Z", + "mediaUrl" => "https://voice.bandwidth.com/api/v2/accounts/1/media", + "to" => "+15551230000", + "from" => "+15557654321" + }.to_json, + { "CONTENT_TYPE" => "application/json" } + ) + + assert last_response.ok? + assert_equal( + "" \ + "The number you have dialled is not in service." \ + "", + last_response.body + ) + end + em :test_voicemail_no_customer end diff --git a/views/inbound/no_customer.slim b/views/inbound/no_customer.slim new file mode 100644 index 0000000000000000000000000000000000000000..1d52949bedd5efdf01f995b57304db1d670f0d94 --- /dev/null +++ b/views/inbound/no_customer.slim @@ -0,0 +1,3 @@ +doctype xml +Response + SpeakSentence The number you have dialled is not in service. diff --git a/web.rb b/web.rb index d79a1828ca3084108b54c1c0b4959fec35000183..799c60c506203ea3d7f64636a7de83efe6c7b163 100644 --- a/web.rb +++ b/web.rb @@ -301,6 +301,8 @@ class Web < Roda next render :hangup unless ogm render :voicemail, locals: { ogm: ogm } + }.catch_only(CustomerRepo::NotFound) { + render "inbound/no_customer" } end end