Prevent math errors in calculating ticket 'turnover'

This commit is contained in:
James Mason 2018-10-08 08:52:58 -07:00
parent d0f673b73d
commit 3031bb43cf
No known key found for this signature in database
GPG key ID: 1B3951886C449023
5 changed files with 7 additions and 13 deletions

View file

@ -71,7 +71,7 @@ describe Ticket do
let!(:purchase1) { create :ticket_purchase, ticket: ticket, amount_paid: 5_000, quantity: 1, paid: true, user: user }
let!(:purchase2) { create :ticket_purchase, ticket: ticket, amount_paid: 5_000, quantity: 2, paid: true, user: user }
let!(:purchase3) { create :ticket_purchase, ticket: ticket, amount_paid: 5_000, quantity: 10, paid: false, user: user }
subject { ticket.tickets_turnover_total ticket.id }
subject { ticket.tickets_turnover_total }
it 'returns turnover as Money with ticket\'s currency' do
is_expected.to eq Money.new(5_000 * 3, ticket.price_currency)