Display paid and unpaid tickets in admin/tickets#show

This commit is contained in:
shlok007 2017-01-23 09:19:15 +05:30
parent c552d08b8e
commit d974807134
3 changed files with 16 additions and 21 deletions

View file

@ -64,24 +64,6 @@ describe Ticket do
end
end
describe '#paid?' do
let!(:ticket_purchase) { create(:ticket_purchase, user: user, ticket: ticket) }
context 'user has paid' do
before { ticket_purchase.update_attributes(paid: true) }
it 'returns true' do
expect(ticket.paid?(user)).to eq(true)
end
end
context 'user has not paid' do
it 'returns false' do
expect(ticket.paid?(user)).to eq(false)
end
end
end
describe '#unpaid?' do
let!(:ticket_purchase) { create(:ticket_purchase, user: user, ticket: ticket) }
@ -101,6 +83,17 @@ describe Ticket do
end
end
describe '#tickets_paid' do
before do
create(:ticket_purchase, user: user, ticket: ticket)
create(:ticket_purchase, user: user, ticket: ticket, paid: true)
end
it 'returns correct number of paid/total tickets' do
expect(ticket.tickets_paid(user)).to eq('10/20')
end
end
describe '#quantity_bought_by' do
context 'user has not paid' do
it 'returns the correct value if the user has bought this ticket' do