diff --git a/lib/porting_step_repo.rb b/lib/porting_step_repo.rb index 508cf608856eddbcf464e497065c13cd828f23b0..9f3d4c15d36804eab33155704e0506ee163491f1 100644 --- a/lib/porting_step_repo.rb +++ b/lib/porting_step_repo.rb @@ -159,11 +159,11 @@ class PortingStepRepo next NoCustomer.for(port: port, **to_h.except(:exe)) unless form.tel tel = Tel.new(port.tel) - good = GoodNumber.new(**to_h).find(port) + good = GoodNumber.new(**to_h) wrong = WrongNumber.new( right_number: tel, execution: @exe, new_backend: port.backend_sgx ) - tel == Tel.new(form.tel) ? good : wrong + tel == Tel.new(form.tel) ? good.find(port) : wrong end end diff --git a/test/test_porting_step.rb b/test/test_porting_step.rb index 8972a124b0bb3ec0acdb1a85a408e012b84ae735..f7929de64e0857065aadccee96ced23ee7f26197 100644 --- a/test/test_porting_step.rb +++ b/test/test_porting_step.rb @@ -213,6 +213,46 @@ class PortingStepTest < Minitest::Test end em :test_change_number + def test_change_number_does_not_invoke_reachability + redis = Minitest::Mock.new + redis.expect(:exists, EMPromise.resolve(0), ["jmp_port_freeze-01"]) + redis.expect(:exists, "0", ["jmp_port_complete-01"]) + + notify = BlatherNotifyMock.new + notify.expect_execution( + "sgx", "customer info", + { q: "starting" }, admin_info("starting", "+19998881111").form + ) + notify.expect(:command_execution, nil) do |_server, node| + if node == "reachability" + raise( + Minitest::Assertion, + "reachability must not be invoked before backend change" + ) + end + false + end + + step = PortingStepRepo.new( + redis: redis, + blather_notify: notify, + admin_server: "sgx" + ).find(Port.new( + "01", + "COMPLETE", + DateTime.now - 25 * MINS, + DateTime.now - 1 * MINS, + "starting", + "9998887777", + Blather::JID.new("testroute") + )).sync + + assert_kind_of( + PortingStepRepo::Complete::AdminCommand::WrongNumber, step + ) + end + em :test_change_number_does_not_invoke_reachability + def test_unknown_customer redis = Minitest::Mock.new redis.expect(:exists, EMPromise.resolve(0), ["jmp_port_freeze-01"])