From c60352cf1c2d450a6f8823800f3f74d372fcfab6 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 9 Apr 2025 11:14:04 -0500 Subject: [PATCH] Add test for onboarding getting subaccount --- test/test_registration.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/test_registration.rb b/test/test_registration.rb index 0203207ed58608d4579f2cc13e3a7783bbca807e..d40fd78fc92ca17f79a840afc6306222430c3ded 100644 --- a/test/test_registration.rb +++ b/test/test_registration.rb @@ -357,6 +357,37 @@ class RegistrationTest < Minitest::Test end em :test_write_with_parent_code + def test_write_with_parent_code_onboarding_jid + Command::COMMAND_MANAGER.expect( + :write, + EMPromise.resolve(Blather::Stanza::Iq::Command.new.tap { |iq| + iq.form.fields = [ + { var: "plan_name", value: "test_usd" }, + { var: "code", value: "PARENT_CODE" } + ] + }), + [Matching.new do |iq| + assert_equal :form, iq.form.type + assert_equal( + "You've selected +15555550000 as your JMP number.", + iq.form.instructions.lines.first.chomp + ) + end] + ) + @customer.expect(:jid, Blather::JID.new("test@onboarding.example.com")) + iq = Blather::Stanza::Iq::Command.new + iq.from = "test@onboarding.example.com" + assert_equal( + "Please create a new Jabber ID before creating a subaccount.", + execute_command(iq) { @activation.write.catch(&:to_s) } + ) + assert_mock Command::COMMAND_MANAGER + assert_mock @customer + assert_mock Registration::Activation::Payment + assert_mock Registration::Activation::DB + end + em :test_write_with_parent_code_onboarding_jid + def test_write_with_parent_code_tombed_parent Command::COMMAND_MANAGER.expect( :write,