From 7e4d61d77027df075ac9de12184df915c57c42b0 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Mon, 2 Aug 2021 12:10:34 -0400 Subject: [PATCH] Fix Invites with Empty Guard Turns out every user will start with no attempts, and the code wasn't handling that case. Oops. --- lib/registration.rb | 2 +- test/test_registration.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/registration.rb b/lib/registration.rb index a24720fecd73f1edc6679652835312cd8a4cfceb..1634f63347511b36588a235acf5e714b9ef3d7fe 100644 --- a/lib/registration.rb +++ b/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 diff --git a/test/test_registration.rb b/test/test_registration.rb index c72043dfcb8a8efd1b14fcc92424bf2c00ce737a..bdf654e3d2c5cee54e3548a046a24eb1d144705d 100644 --- a/test/test_registration.rb +++ b/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(