Added model test

Added test for physical ticket model.
This commit is contained in:
Siddhant Bajaj 2017-06-08 03:45:08 +05:30 committed by siddhantbajaj
parent 5c56683ae8
commit d7678b2fa0
4 changed files with 25 additions and 18 deletions

View file

@ -114,22 +114,4 @@ describe TicketPurchase do
expect(message.blank?).to be true
end
end
describe 'after_create' do
let(:ticket_purchase) { create(:ticket_purchase, quantity: 4, paid: true) }
it 'creates physical tickets equal to the quantity of purchase' do
expect(ticket_purchase.physical_tickets.count).to eq(4)
end
end
describe 'after_update' do
let(:ticket_purchase) { create(:ticket_purchase, quantity: 5) }
it 'creates physical tickets if the payment is made successfully' do
ticket_purchase
ticket_purchase.paid = true
expect{ ticket_purchase.save }.to change{ ticket_purchase.physical_tickets.count }.from(0).to(5)
end
end
end