~singpolyma/sgx-jmp

274677be9df4fa3f5332beed5c311e39a7a5d9ac — Stephen Paul Weber 11 months ago 52fad25
Braintree can't charge for sub-cent, so make sure it doesn't try
2 files changed, 4 insertions(+), 4 deletions(-)

M lib/low_balance.rb
M test/test_low_balance.rb
M lib/low_balance.rb => lib/low_balance.rb +2 -2
@@ 95,7 95,7 @@ class LowBalance

		def top_up_amount
			[
				(@target + @margin) - @customer.balance,
				((@target + @margin) - @customer.balance).round(2),
				@customer.auto_top_up_amount
			].max
		end


@@ 116,7 116,7 @@ class LowBalance
			)
			@message.body =
				"Automatic top-up transaction for " \
				"$#{top_up_amount} failed: #{e.message}"
				"$#{'%.2f' % top_up_amount} failed: #{e.message}"
			0
		end


M test/test_low_balance.rb => test/test_low_balance.rb +2 -2
@@ 246,7 246,7 @@ class LowBalanceTest < Minitest::Test
				nil,
				[Matching.new { |m|
					assert_equal(
						"Automatic top-up transaction for $100 failed: test",
						"Automatic top-up transaction for $100.00 failed: test",
						m.body
					)
				}]


@@ 254,7 254,7 @@ class LowBalanceTest < Minitest::Test
			LowBalance::AutoTopUp::CreditCardSale.expect(
				:create,
				EMPromise.reject(RuntimeError.new("test")),
				[@customer], amount: 100
				[@customer], amount: 100.to_d
			)
			@auto_top_up.notify!.sync
			assert_mock @customer