Fix tickets turnover calculation

This commit is contained in:
Michael Klimenko 2018-03-24 01:24:49 +05:00 committed by James Mason
parent 69de418ccd
commit 58cb62dd6d
3 changed files with 20 additions and 6 deletions

View file

@ -65,6 +65,17 @@ describe Ticket do
end
end
describe '#tickets_turnover_total' 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 }
it 'returns turnover as Money with ticket\'s currency' do
is_expected.to eq Money.new(5_000 * 3, ticket.price_currency)
end
end
describe '#unpaid?' do
let!(:ticket_purchase) { create(:ticket_purchase, user: user, ticket: ticket) }