diff --git a/lib/registration.rb b/lib/registration.rb
index 4529c556a1ad49ed7f50fec8701d981f33c89c02..4ff149483b2b819a9607252dbc9313e4fae02b11 100644
--- a/lib/registration.rb
+++ b/lib/registration.rb
@@ -145,7 +145,7 @@ class Registration
tel_selections[customer]
}.then { |choose|
choose.choose_tel_or_data(
- error: "The JMP number #{tel} is no longer available."
+ error: "The JMP number #{product} is no longer available."
)
}.then { |n_tel| reserve_and_continue(tel_selections, customer, n_tel) }
end
diff --git a/lib/tel_selections.rb b/lib/tel_selections.rb
index 27ab730f06669c7b1a23dbc454e796fc883def70..146869a81231549539a3c51bd5c74d470953e5a2 100644
--- a/lib/tel_selections.rb
+++ b/lib/tel_selections.rb
@@ -59,7 +59,7 @@ class TelSelections
@tel = ChooseTel::Tn.for_pending_value(tel)
end
- def choose_tel_or_data
+ def choose_tel_or_data(**)
EMPromise.resolve(@tel)
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 7c3f0ebe4676b41cc9bd981fd317b80af3958056..e65696a9cceebbd16ee934876700fbca64730b5b 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -383,6 +383,10 @@ class FakeRedis
set(key, n).then { n }
}
end
+
+ def reset!
+ @values = {}
+ end
end
class FakeDB
diff --git a/test/test_registration.rb b/test/test_registration.rb
index fca4eeb1c673c7e06feb801713ad60fd6ff32535..94437ff468321df8ac248b0f4aa61d6e9d90ef39 100644
--- a/test/test_registration.rb
+++ b/test/test_registration.rb
@@ -10,6 +10,11 @@ require "sim_order"
BandwidthTnReservationRepo::REDIS = FakeRedis.new
class RegistrationTest < Minitest::Test
+ def teardown
+ BandwidthTnReservationRepo::REDIS.reset!
+ WebMock.reset!
+ end
+
def test_for_registered
sgx = OpenStruct.new(
registered?: OpenStruct.new(phone: "+15555550000")
@@ -141,6 +146,72 @@ class RegistrationTest < Minitest::Test
end
em :test_for_not_activated_with_customer_id
+ def test_reserve_and_continue_retries_on_reserve_failure
+ redis = Minitest::Mock.new
+ redis.expect(:del, EMPromise.resolve(1), [String])
+ redis.expect(:get, EMPromise.resolve("+15555551111"), [String])
+ first_res = stub_request(
+ :post,
+ "https://dashboard.bandwidth.com/v1.0/accounts//tnreservation"
+ ).with(
+ body: '' \
+ "+15555550000",
+ headers: {
+ "Accept" => "application/xml",
+ "Authorization" => "Basic Og==",
+ "Content-Type" => "application/xml",
+ "User-Agent" => "Ruby-Bandwidth-Iris"
+ }
+ ).to_return(status: 400, body: "", headers: {})
+ second_res = stub_request(
+ :post,
+ "https://dashboard.bandwidth.com/v1.0/accounts//tnreservation"
+ ).with(
+ body: '' \
+ "+15555551111",
+ headers: {
+ "Accept" => "application/xml",
+ "Authorization" => "Basic Og==",
+ "Content-Type" => "application/xml",
+ "User-Agent" => "Ruby-Bandwidth-Iris"
+ }
+ ).to_return(
+ status: 201,
+ headers: {
+ location: "https://dashboard.bandwidth.com/api/accounts//TnReservation/retry-test-reservation"
+ }
+ )
+ check_res = stub_request(
+ :get, "https://dashboard.bandwidth.com/v1.0/accounts//tnreservation/retry-test-reservation"
+ ).to_return(status: 200, body: <<~RESPONSE)
+
+
+ retry-test-reservation
+ 12346099
+ 1492
+ 5555551111
+
+
+ RESPONSE
+
+ tel_selections = TelSelections.new(
+ redis: redis, db: Minitest::Mock.new, memcache: FakeMemcache.new
+ )
+
+ cust = customer(sgx: OpenStruct.new(registered?: false))
+ first_tel = TelSelections::ChooseTel::Tn.for_pending_value("+15555550000")
+
+ execute_command do
+ Registration.reserve_and_continue(tel_selections, cust, first_tel)
+ end
+
+ [first_res, second_res, check_res].each do |req|
+ assert_requested req
+ end
+ assert_mock redis
+ end
+ em :test_reserve_and_continue_retries_on_reserve_failure
+
class ActivationTest < Minitest::Test
Registration::Activation::DB = Minitest::Mock.new
Registration::Activation::REDIS = FakeRedis.new(