refactor: remove duplicated logic from BuyAccountCreditForm

Amolith created

Change summary

lib/buy_account_credit_form.rb       |  6 +-----
test/test_buy_account_credit_form.rb | 11 -----------
2 files changed, 1 insertion(+), 16 deletions(-)

Detailed changes

lib/buy_account_credit_form.rb 🔗

@@ -52,11 +52,7 @@ class BuyAccountCreditForm
 		amount = form.field("amount")&.value&.to_s
 		amount_value = amount.to_f
 
-		if amount_value < 15
-			raise AmountTooLowError.new(amount_value, 15)
-		elsif amount_value > @max_top_up_amount
-			raise AmountTooHighError.new(amount_value, @max_top_up_amount)
-		end
+		raise AmountTooLowError.new(amount_value, 15) if amount_value < 15
 
 		{
 			payment_method: @payment_methods.fetch(

test/test_buy_account_credit_form.rb 🔗

@@ -105,15 +105,4 @@ class BuyAccountCreditFormTest < Minitest::Test
 			@form.parse(iq_form)
 		end
 	end
-
-	def test_parse_amount_too_high
-		iq_form = Blather::Stanza::X.new
-		iq_form.fields = [
-			{ var: "payment_method", value: "0" },
-			{ var: "amount", value: "200" }
-		]
-		assert_raises(AmountTooHighError) do
-			@form.parse(iq_form)
-		end
-	end
 end