From 63f818433ee9563bddc45cfac3e40b16ce2aab3b Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:51:30 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=97=20`Tobias`:=20Confirm=20issuing=20?= =?UTF-8?q?indivisible=20`Payout#amount`=20rounds=20each=20`Beneficiary`?= =?UTF-8?q?=20`Payment`=20down?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I wasn't exactly sure what would happen, so I took the time to figure it out. Apparently, the [`money-rails` gem] we use defaults to rounding down, which is the safer thing to do. [`money-rails` gem]: https://github.com/RubyMoney/money-rails --- spec/tobias/payout_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/tobias/payout_spec.rb b/spec/tobias/payout_spec.rb index afcbc3ee1..53556bfe7 100644 --- a/spec/tobias/payout_spec.rb +++ b/spec/tobias/payout_spec.rb @@ -15,5 +15,19 @@ expect(beneficiary.payments).to exist(amount_cents: 15_00) end end + + context "when the Payout#amount does not divide evenly" do + it "rounds down so that it can" do + payout = create(:tobias_payout, amount_cents: 3_33) + + beneficiaries = create_list(:tobias_beneficiary, 2, trust: payout.trust) + + payout.issue + + beneficiaries.each do |beneficiary| + expect(beneficiary.payments).to exist(amount_cents: 1_66) + end + end + end end end