~singpolyma/sgx-jmp

6e32ea129b50f6ce7b4846f5326a528dd2ed090a — Stephen Paul Weber 1 year, 11 months ago 9037e5c + 1c4bb40
Merge branch 'ruby3'

* ruby3:
  Fix for ruby3
  Test on Ubuntu LTS (with ruby3)
  Update to new minitest
A .builds/ubuntu-lts.yml => .builds/ubuntu-lts.yml +26 -0
@@ 0,0 1,26 @@
image: ubuntu/lts
sources:
- https://git.sr.ht/~singpolyma/sgx-jmp
packages:
- ruby
- ruby-dev
- bundler
- libxml2-dev
- libpq-dev
- rubocop
environment:
  LANG: C.UTF-8
tasks:
- dependencies: |
    cd sgx-jmp
    bundle install --without=development --path=.gems
- lint: |
    cd sgx-jmp
    rubocop
- test: |
    cd sgx-jmp
    RANTLY_COUNT=100 bundle exec rake test
- check_config_sample: |
    curl -LO https://github.com/dhall-lang/dhall-haskell/releases/download/1.39.0/dhall-1.39.0-x86_64-linux.tar.bz2
    tar -xf dhall-*.tar.bz2
    echo "./sgx-jmp/config.dhall.sample : ./sgx-jmp/config-schema.dhall" | bin/dhall --plain

M Gemfile => Gemfile +1 -1
@@ 34,7 34,7 @@ group(:development) do
end

group(:test) do
	gem "minitest", "<= 5.15.0"
	gem "minitest", ">= 5.16.0"
	gem "rack-test"
	gem "rake"
	gem "rantly"

M lib/customer.rb => lib/customer.rb +1 -1
@@ 41,7 41,7 @@ class Customer

		klass.new(
			customer_id, jid,
			plan: CustomerPlan.extract(customer_id, kwargs),
			plan: CustomerPlan.extract(customer_id, **kwargs),
			**kwargs.slice(:balance, :sgx, :tndetails, *keys)
		)
	end

M lib/registration.rb => lib/registration.rb +1 -1
@@ 225,7 225,7 @@ class Registration
		end

		class CreditCard
			Payment.kinds[:credit_card] = ->(*args) { self.for(*args) }
			Payment.kinds[:credit_card] = ->(*args, **kw) { self.for(*args, **kw) }

			def self.for(customer, tel, finish: Finish, **)
				customer.payment_methods.then do |payment_methods|

M test/test_customer_info.rb => test/test_customer_info.rb +1 -1
@@ 75,7 75,7 @@ class CustomerInfoTest < Minitest::Test
		call_attempt_repo.expect(
			:find_outbound,
			CallAttempt::Unsupported.new(direction: :outbound),
			[cust, "+1", { call_id: "dry_run" }]
			[cust, "+1"], call_id: "dry_run"
		)

		trust_repo = Minitest::Mock.new

M test/test_low_balance.rb => test/test_low_balance.rb +4 -4
@@ 131,7 131,7 @@ class LowBalanceTest < Minitest::Test
			LowBalance::AutoTopUp::Transaction.expect(
				:sale,
				tx,
				[@customer, { amount: 100 }]
				[@customer], amount: 100
			)
			@auto_top_up.notify!
			assert_mock tx


@@ 150,7 150,7 @@ class LowBalanceTest < Minitest::Test
			LowBalance::AutoTopUp::Transaction.expect(
				:sale,
				tx,
				[customer, { amount: 115 }]
				[customer], amount: 115
			)
			auto_top_up.notify!
			assert_mock tx


@@ 169,7 169,7 @@ class LowBalanceTest < Minitest::Test
			LowBalance::AutoTopUp::Transaction.expect(
				:sale,
				tx,
				[customer, { amount: 26 }]
				[customer], amount: 26
			)
			auto_top_up.notify!
			assert_mock tx


@@ 190,7 190,7 @@ class LowBalanceTest < Minitest::Test
			LowBalance::AutoTopUp::Transaction.expect(
				:sale,
				EMPromise.reject(RuntimeError.new("test")),
				[@customer, { amount: 100 }]
				[@customer], amount: 100
			)
			@auto_top_up.notify!.sync
			assert_mock @customer

M test/test_registration.rb => test/test_registration.rb +1 -1
@@ 435,7 435,7 @@ class RegistrationTest < Minitest::Test
				customer.expect(
					:bill_plan,
					nil,
					[{ note: "Bill +15555550000 for first month" }]
					note: "Bill +15555550000 for first month"
				)
				Registration::Payment::CreditCard::Activate::Finish.expect(
					:new,

M test/test_transaction.rb => test/test_transaction.rb +12 -11
@@ 33,7 33,7 @@ class TransactionTest < Minitest::Test
		TrustLevelRepo::DB.expect(
			:query_one,
			EMPromise.resolve({}),
			[String, "test", Hash]
			[String, "test"], default: {}
		)
		CustomerFinancials::REDIS.expect(
			:get,


@@ 57,9 57,12 @@ class TransactionTest < Minitest::Test
			EMPromise.resolve(
				OpenStruct.new(success?: false, message: "declined")
			),
			[Hash]
			amount: 99,
			merchant_account_id: "merchant_usd",
			options: { submit_for_settlement: true },
			payment_method_token: "token"
		)
		assert_raises("declined") do
		assert_raises(RuntimeError) do
			Transaction.sale(
				customer(plan_name: "test_usd"),
				amount: 99,


@@ 87,7 90,7 @@ class TransactionTest < Minitest::Test
		TrustLevelRepo::DB.expect(
			:query_one,
			EMPromise.resolve({}),
			[String, "test", Hash]
			[String, "test"], default: {}
		)
		CustomerFinancials::REDIS.expect(
			:get,


@@ 122,7 125,7 @@ class TransactionTest < Minitest::Test
		TrustLevelRepo::DB.expect(
			:query_one,
			EMPromise.resolve({}),
			[String, "test", Hash]
			[String, "test"], default: {}
		)
		CustomerFinancials::REDIS.expect(
			:get,


@@ 139,12 142,10 @@ class TransactionTest < Minitest::Test
					transaction: FAKE_BRAINTREE_TRANSACTION
				)
			),
			[{
				amount: 99,
				payment_method_token: "token",
				merchant_account_id: "merchant_usd",
				options: { submit_for_settlement: true }
			}]
			amount: 99,
			payment_method_token: "token",
			merchant_account_id: "merchant_usd",
			options: { submit_for_settlement: true }
		)
		Transaction::REDIS.expect(
			:setex,

M test/test_web.rb => test/test_web.rb +16 -20
@@ 161,7 161,7 @@ class WebTest < Minitest::Test
			EMPromise.resolve(
				OpenStruct.new(insert: EMPromise.resolve(nil), total: 15)
			),
			[Customer, { amount: 15 }]
			[Customer], amount: 15
		)

		ExpiringLock::REDIS.expect(


@@ 291,16 291,13 @@ class WebTest < Minitest::Test
		CustomerFwd::BANDWIDTH_VOICE.expect(
			:create_call,
			OpenStruct.new(data: OpenStruct.new(call_id: "ocall")),
			[
				"test_bw_account",
				Matching.new do |arg|
					assert_equal(
						"http://example.org/inbound/calls/acall?customer_id=customerid",
						arg[:body].answer_url
					)
					assert_equal [:body], arg.keys
				end
			]
			["test_bw_account"],
			body: Matching.new do |arg|
				assert_equal(
					"http://example.org/inbound/calls/acall?customer_id=customerid",
					arg.answer_url
				)
			end
		)

		post(


@@ 429,15 426,14 @@ class WebTest < Minitest::Test
			nil,
			[
				"test_bw_account",
				"bcall",
				Matching.new do |arg|
					assert_equal [:body], arg.keys
					assert_equal(
						"http://example.org/inbound/calls/oocall/voicemail",
						arg[:body].redirect_url
					)
				end
			]
				"bcall"
			],
			body: Matching.new do |arg|
				assert_equal(
					"http://example.org/inbound/calls/oocall/voicemail",
					arg.redirect_url
				)
			end
		)

		post(