~singpolyma/sgx-jmp

c4fc3de0cbe19bdf4d107c594fff514f281cee5f — Stephen Paul Weber 1 year, 6 months ago 7a28753
Revert "Merge branch 'limit-top-up-freq'"

This reverts commit 7a28753d7df5d7d6f5f890d302634b1bdbd25f73, reversing
changes made to e4ec9b8eb368ed0997887ebd99f8c79982640d20.
2 files changed, 1 insertions(+), 16 deletions(-)

M lib/transaction.rb
M test/test_transaction.rb
M lib/transaction.rb => lib/transaction.rb +1 -3
@@ 18,11 18,9 @@ class Transaction

	def self.resolve_payment_method(customer, payment_method)
		EMPromise.all([
			ExpiringLock.new("jmp_customer_credit_card_lock-#{customer.customer_id}")
				.with(els: -> { raise "Too many transactions today" }) { nil },
			customer.declines,
			payment_method || customer.payment_methods.then(&:default_payment_method)
		]).then do |(_, declines, selected_method)|
		]).then do |(declines, selected_method)|
			raise "Declined" if declines >= 2
			raise "No valid payment method on file" unless selected_method


M test/test_transaction.rb => test/test_transaction.rb +0 -13
@@ 7,7 7,6 @@ require "transaction"
Transaction::DB = Minitest::Mock.new
Transaction::BRAINTREE = Minitest::Mock.new
Transaction::REDIS = Minitest::Mock.new
ExpiringLock::REDIS = Minitest::Mock.new

class TransactionTest < Minitest::Test
	FAKE_BRAINTREE_TRANSACTION =


@@ 19,11 18,6 @@ class TransactionTest < Minitest::Test
		)

	def test_sale_fails
		ExpiringLock::REDIS.expect(
			:set,
			EMPromise.resolve("OK"),
			["jmp_customer_credit_card_lock-test", Time, "EX", 86400, "NX"]
		)
		CustomerFinancials::REDIS.expect(
			:get,
			EMPromise.resolve("1"),


@@ 56,16 50,10 @@ class TransactionTest < Minitest::Test
			).sync
		end
		assert_mock CustomerFinancials::REDIS
		assert_mock ExpiringLock::REDIS
	end
	em :test_sale_fails

	def test_sale
		ExpiringLock::REDIS.expect(
			:set,
			EMPromise.resolve("OK"),
			["jmp_customer_credit_card_lock-test", Time, "EX", 86400, "NX"]
		)
		CustomerFinancials::REDIS.expect(
			:get,
			EMPromise.resolve("1"),


@@ 95,7 83,6 @@ class TransactionTest < Minitest::Test
		).sync
		assert_kind_of Transaction, result
		assert_mock CustomerFinancials::REDIS
		assert_mock ExpiringLock::REDIS
	end
	em :test_sale