~singpolyma/sgx-jmp

6e0b6b1776c9c6447a3aefb0480b8b4353fe5308 — Stephen Paul Weber 5 days ago 07c3da0 + f5ad677
Merge branch 'outbound-call-customer-not-found'

* outbound-call-customer-not-found:
  Actually handle outbound attempt from unknown customer
3 files changed, 28 insertions(+), 2 deletions(-)

M test/test_web.rb
A views/outbound/no_customer.slim
M web.rb
M test/test_web.rb => test/test_web.rb +21 -0
@@ 265,6 265,27 @@ class WebTest < Minitest::Test
	end
	em :test_outbound_atlimit

	def test_outbound_no_customer
		post(
			"/outbound/calls",
			{
				from: "no_such_customer",
				to: "+15557654321",
				callId: "acall"
			}.to_json,
			{ "CONTENT_TYPE" => "application/json" }
		)

		assert last_response.ok?
		assert_equal(
			"<?xml version=\"1.0\" encoding=\"utf-8\" ?><Response>" \
			"<SpeakSentence>Your credentials are invalid, please contact support." \
			"</SpeakSentence></Response>",
			last_response.body
		)
	end
	em :test_outbound_no_customer

	def test_outbound_atlimit_digits
		post(
			"/outbound/calls",

A views/outbound/no_customer.slim => views/outbound/no_customer.slim +3 -0
@@ 0,0 1,3 @@
doctype xml
Response
	SpeakSentence Your credentials are invalid, please contact support.

M web.rb => web.rb +4 -2
@@ 368,7 368,7 @@ class Web < Roda
					from = params["from"].sub(/^\+1/, "")
					customer_repo(
						sgx_repo: Bwmsgsv2Repo.new
					).find_by_format(from).then do |c|
					).find_by_format(from).then { |c|
						call_attempt_repo.find_outbound(
							c,
							params["to"],


@@ 380,7 380,9 @@ class Web < Roda
							call_attempt_repo.starting_call(c, params["callId"])
							render(*ca.to_render)
						end
					end
					}.catch_only(CustomerRepo::NotFound) {
						render "outbound/no_customer"
					}
				end
			end
		end