Fix sentry issue SGX-JMP-4

Stephen Paul Weber created

Typo not caught by tests because this method had none.  Add a test, fix the typo.

Change summary

lib/buy_account_credit_form.rb       |  2 +-
test/test_buy_account_credit_form.rb | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)

Detailed changes

lib/buy_account_credit_form.rb 🔗

@@ -4,7 +4,7 @@ require_relative "./xep0122_field"
 
 class BuyAccountCreditForm
 	def self.for(customer)
-		@customer.payment_methods.then do |payment_methods|
+		customer.payment_methods.then do |payment_methods|
 			new(customer.balance, payment_methods)
 		end
 	end

test/test_buy_account_credit_form.rb 🔗

@@ -4,6 +4,8 @@ require "test_helper"
 require "buy_account_credit_form"
 require "customer"
 
+Customer::BRAINTREE = Minitest::Mock.new
+
 class BuyAccountCreditFormTest < Minitest::Test
 	def setup
 		@payment_method = OpenStruct.new(card_type: "Test", last_4: "1234")
@@ -13,6 +15,20 @@ class BuyAccountCreditFormTest < Minitest::Test
 		)
 	end
 
+	def test_for
+		braintree_customer = Minitest::Mock.new
+		Customer::BRAINTREE.expect(:customer, braintree_customer)
+		braintree_customer.expect(:find, EMPromise.resolve(
+			OpenStruct.new(payment_methods: [])
+		), ["test"])
+
+		assert_kind_of(
+			BuyAccountCreditForm,
+			BuyAccountCreditForm.for(Customer.new("test")).sync
+		)
+	end
+	em :test_for
+
 	def test_balance
 		assert_equal(
 			{ type: "fixed", value: "Current balance: $12.12" },