From 5f9590c941d6f685acfe089334acf3f845bfa444 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 23 Feb 2024 22:18:17 -0500 Subject: [PATCH] Remove upper bound on top up It's wrong anyway, since trust levels impose different upper bounds, and all we really care about here is min. --- lib/buy_account_credit_form.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/buy_account_credit_form.rb b/lib/buy_account_credit_form.rb index 1c3cca0519184be1713d82a8be782c90d2f64091..b6a1da671cb6c4c17886ed433c7dc2ff56e5a828 100644 --- a/lib/buy_account_credit_form.rb +++ b/lib/buy_account_credit_form.rb @@ -3,10 +3,7 @@ class BuyAccountCreditForm class AmountValidationError < StandardError def initialize(amount) - super( - "amount #{amount} must be in the range " \ - "#{RANGE.first} through #{RANGE.last}" - ) + super("amount #{amount} must be more than $15") end end @@ -21,20 +18,18 @@ class BuyAccountCreditForm @payment_methods = payment_methods end - RANGE = (15..1000).freeze - def form FormTemplate.render( :top_up, balance: @balance, payment_methods: @payment_methods, - range: RANGE + range: [15, nil] ) end def parse(form) amount = form.field("amount")&.value&.to_s - raise AmountValidationError, amount unless RANGE.include?(amount.to_i) + raise AmountValidationError, amount unless amount.to_i >= 15 { payment_method: @payment_methods.fetch(