56ce8534f7ec971faebb7d863aebf71129cefd71 — Stephen Paul Weber 2 years ago c69a621
Already activated user goes straight to finish

If not registered, but activated, they must have paid but failed to get their
number setup. Maybe the number was already taken. Maybe they paid manually. In
any case we can skip all intervening steps and go straight to buying and
configuring their number for them.
2 files changed, 22 insertions(+), 8 deletions(-)

M lib/registration.rb
M test/test_registration.rb
M lib/registration.rb => lib/registration.rb +8 -6
@@ 4,8 4,6 @@ require_relative "./oob"

class Registration
	def self.for(iq, customer, web_register_manager)
		raise "TODO" if customer&.active?

		EMPromise.resolve(customer&.registered?).then do |registered|
			if registered
				Registered.new(iq, registered.phone)

@@ 36,10 34,14 @@ class Registration

	class Activation
		def self.for(iq, customer, tel)
			return EMPromise.resolve(new(iq, customer, tel)) if customer

			# Create customer_id
			raise "TODO"
			if customer&.active?
				Finish.new(iq, customer, tel)
			elsif customer
				EMPromise.resolve(new(iq, customer, tel))
				# Create customer_id
				raise "TODO"

		def initialize(iq, customer, tel)

M test/test_registration.rb => test/test_registration.rb +14 -2
@@ 5,9 5,21 @@ require "registration"

class RegistrationTest < Minitest::Test
	def test_for_activated
		skip "Registration#for activated not implemented yet"
		web_manager = WebRegisterManager.new
		web_manager["test@example.com"] = "+15555550000"
		iq = Blather::Stanza::Iq::Command.new
		Registration.for(iq, Customer.new("test"), Minitest::Mock.new).sync
		iq.from = "test@example.com"
		result = Registration.for(
			Customer.new("test", plan_name: "test_usd", expires_at: Time.now + 999),
		assert_kind_of Registration::Finish, result
	em :test_for_activated