diff --git a/lib/porting_step_repo.rb b/lib/porting_step_repo.rb index b9f15adeabbf1087c80b4c8314c60ce18c961444..4090928d6d63d653057d2824685d9d85d8701ae8 100644 --- a/lib/porting_step_repo.rb +++ b/lib/porting_step_repo.rb @@ -137,11 +137,12 @@ class PortingStepRepo end def find(port) + h = to_h @exe.fetch_and_submit(q: port.customer_id).then do |form| - next NoCustomer.for(port: port, **to_h.except(:exe)) unless form.tel + next NoCustomer.for(port: port, **h.except(:exe)) unless form.tel - if port.tel == form.tel - GoodNumber.new(**to_h).find(port) + if port.tel == form.tel && form.route == port.backend_sgx.to_s + GoodNumber.new(**h).find(port) else WrongNumber.new(port: port, execution: @exe) end diff --git a/test/test_porting_step.rb b/test/test_porting_step.rb index d04a8a9c9bf0126159ede9788c2062c9985a0a0c..ade9f89aaaac3c1592fd9b1cf1f960dcc5d21a73 100644 --- a/test/test_porting_step.rb +++ b/test/test_porting_step.rb @@ -213,6 +213,47 @@ class PortingStepTest < Minitest::Test end em :test_change_number + def test_change_backend_only + 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", "+19998887777").form + ) + notify.expect(:command_execution, nil) do |_server, node| + if node == "reachability" + raise( + Minitest::Assertion, + "reachability must not be invoked when backend needs to 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", + "+19998887777", + Blather::JID.new("newroute") + )).sync + + assert_kind_of( + PortingStepRepo::Complete::AdminCommand::WrongNumber, step + ) + assert_equal Blather::JID.new("newroute"), step.new_backend + end + em :test_change_backend_only + def test_change_number_does_not_invoke_reachability redis = Minitest::Mock.new redis.expect(:exists, EMPromise.resolve(0), ["jmp_port_freeze-01"])