lib/port_repo.rb 🔗
@@ -39,7 +39,7 @@ class PortRepo
end
def tel
- self[:billing_telephone_number]
+ "+1#{self[:billing_telephone_number].sub(/^\+?1?/, '')}"
end
def updated_at
Stephen Paul Weber created
lib/port_repo.rb | 2 +-
lib/porting_step_repo.rb | 39 ++++++++-------------------------------
test/test_port_repo.rb | 2 +-
test/test_porting_step.rb | 38 +++++++++++++++++++-------------------
4 files changed, 29 insertions(+), 52 deletions(-)
@@ -39,7 +39,7 @@ class PortRepo
end
def tel
- self[:billing_telephone_number]
+ "+1#{self[:billing_telephone_number].sub(/^\+?1?/, '')}"
end
def updated_at
@@ -8,24 +8,6 @@ require_relative "blather_notify"
require_relative "utils"
class PortingStepRepo
- class Tel
- def initialize(str)
- @tel = if str.is_a? Tel
- str.to_s
- else
- "+1#{str.sub(/^\+?1?/, '')}"
- end
- end
-
- def to_s
- @tel
- end
-
- def ==(other)
- to_s == other.to_s
- end
- end
-
# Any thing that debounces messages must happen inside this.
# The porting logic will pass everything in every time.
class Outputs
@@ -158,12 +140,11 @@ class PortingStepRepo
@exe.fetch_and_submit(q: port.customer_id).then do |form|
next NoCustomer.for(port: port, **to_h.except(:exe)) unless form.tel
- tel = Tel.new(port.tel)
- good = GoodNumber.new(**to_h)
- wrong = WrongNumber.new(
- right_number: tel, execution: @exe, new_backend: port.backend_sgx
- )
- tel == Tel.new(form.tel) ? good.find(port) : wrong
+ if port.tel == form.tel
+ GoodNumber.new(**to_h).find(port)
+ else
+ WrongNumber.new(port: port, execution: @exe)
+ end
end
end
@@ -295,13 +276,9 @@ class PortingStepRepo
class WrongNumber
attr_reader :new_backend
- def initialize(
- right_number:,
- execution:,
- new_backend:
- )
- @new_backend = new_backend
- @right_number = right_number
+ def initialize(port:, execution:)
+ @new_backend = port.backend_sgx
+ @right_number = port.tel
@exe = execution
end
@@ -102,7 +102,7 @@ class PortRepoBandwidthTest < Minitest::Test
assert_kind_of PortRepo::Bandwidth::PortWithBackend, port
assert_equal "abc123", port.id
assert_equal "cust456", port.customer_id
- assert_equal "5551234567", port.tel
+ assert_equal "+15551234567", port.tel
assert_equal CONFIG[:sgx], port.backend_sgx
end
end
@@ -299,7 +299,7 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
FormTemplate.render("reachability_result", count: 0)
)
@@ -313,7 +313,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 25 * MINS,
DateTime.now - 1 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)).sync
@@ -341,13 +341,13 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
FormTemplate.render("reachability_result", count: 1)
)
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "sms" },
+ { tel: "+19998887777", type: "sms" },
FormTemplate.render("reachability_result", count: 0)
)
@@ -361,7 +361,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 25 * MINS,
DateTime.now - 1 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)).sync
@@ -389,13 +389,13 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
FormTemplate.render("reachability_result", count: 1)
)
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "sms" },
+ { tel: "+19998887777", type: "sms" },
FormTemplate.render("reachability_result", count: 1)
)
@@ -409,7 +409,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 25 * MINS,
DateTime.now - 1 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)).sync
@@ -435,7 +435,7 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
FormTemplate.render("reachability_result", count: 0)
)
@@ -449,7 +449,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 55 * MINS,
DateTime.now - 50 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)).sync
@@ -474,7 +474,7 @@ class PortingStepTest < Minitest::Test
nil,
DateTime.now - 1 * MINS,
"ignored",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
),
Port.new(
@@ -483,7 +483,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 300 * MINS,
DateTime.now - 300 * MINS,
"ignored",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
),
Port.new(
@@ -492,7 +492,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 10 * MINS,
DateTime.now - 10 * MINS,
"ignored",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
),
Port.new(
@@ -501,7 +501,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 300 * MINS,
DateTime.now - 300 * MINS,
"ignored",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)
].each do |port|
@@ -527,7 +527,7 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
RuntimeError.new("Sender not in whitelist")
)
@@ -541,7 +541,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 25 * MINS,
DateTime.now - 1 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)).sync
@@ -566,13 +566,13 @@ class PortingStepTest < Minitest::Test
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice" },
+ { tel: "+19998887777", type: "voice" },
FormTemplate.render("reachability_result", count: 0)
)
notify.expect_execution(
"sgx", "reachability",
- { tel: "9998887777", type: "voice", reachability_tel: "+15551234567" },
+ { tel: "+19998887777", type: "voice", reachability_tel: "+15551234567" },
RuntimeError.new("Sender not in whitelist")
)
@@ -594,7 +594,7 @@ class PortingStepTest < Minitest::Test
DateTime.now - 25 * MINS,
DateTime.now - 1 * MINS,
"starting",
- "9998887777",
+ "+19998887777",
Blather::JID.new("testroute")
)