Merge pull request #1255 from shlok007/display-paid-and-unpaid-tickets

Display paid and unpaid tickets in admin/tickets#show
This commit is contained in:
Ana María Martínez Gómez 2017-01-26 16:27:24 +01:00 committed by GitHub
commit 45c3c73e57
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