Fix Invites with Empty Guard

Christopher Vollick created

Turns out every user will start with no attempts, and the code wasn't
handling that case. Oops.

Change summary

lib/registration.rb       | 2 +-
test/test_registration.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -376,7 +376,7 @@ class Registration
 
 			def guard_too_many_tries
 				REDIS.get("jmp_invite_tries-#{@customer.customer_id}").then do |t|
-					raise Invalid, "Too many wrong attempts" if t > 10
+					raise Invalid, "Too many wrong attempts" if t.to_i > 10
 				end
 			end
 

test/test_registration.rb 🔗

@@ -354,7 +354,7 @@ class RegistrationTest < Minitest::Test
 				customer = Customer.new("test", plan_name: "test_usd")
 				Registration::Payment::InviteCode::REDIS.expect(
 					:get,
-					EMPromise.resolve(0),
+					EMPromise.resolve(nil),
 					["jmp_invite_tries-test"]
 				)
 				Registration::Payment::InviteCode::COMMAND_MANAGER.expect(