module StripeMock class ErrorQueue def clear @queue = [] end end def self.clear_errors instance.error_queue.clear if instance client.error_queue.clear if client end end def testdrive_lesson(user, teacher, slots = nil) if slots.nil? slots = [] slots << FactoryGirl.build(:lesson_booking_slot_single) slots << FactoryGirl.build(:lesson_booking_slot_single) end if user.stored_credit_card == false user.stored_credit_card = true user.save! end booking = LessonBooking.book_test_drive(user, teacher, slots, "Hey I've heard of you before.") #puts "BOOKING #{booking.errors.inspect}" booking.errors.any?.should be_false lesson = booking.lesson_sessions[0] booking.card_presumed_ok.should be_true if user.most_recent_test_drive_purchase.nil? LessonPackagePurchase.create(user, booking, LessonPackageType.test_drive) end lesson.accept({message: 'Yeah I got this', slot: slots[0]}) lesson.errors.any?.should be_false lesson.reload lesson.slot.should eql slots[0] lesson.status.should eql LessonSession::STATUS_APPROVED lesson end def normal_lesson(user, teacher, slots = nil) if slots.nil? slots = [] slots << FactoryGirl.build(:lesson_booking_slot_single) slots << FactoryGirl.build(:lesson_booking_slot_single) end if user.stored_credit_card == false user.stored_credit_card = true user.save! end booking = LessonBooking.book_normal(user, teacher, slots, "Hey I've heard of you before.", false, LessonBooking::PAYMENT_STYLE_SINGLE, 60) # puts "NORMAL BOOKING #{booking.errors.inspect}" booking.errors.any?.should be_false lesson = booking.lesson_sessions[0] booking.card_presumed_ok.should be_true #if user.most_recent_test_drive_purchase.nil? # LessonPackagePurchase.create(user, booking, LessonPackageType.test_drive) #end lesson.accept({message: 'Yeah I got this', slot: slots[0]}) lesson.errors.any?.should be_false lesson.reload lesson.slot.should eql slots[0] lesson.status.should eql LessonSession::STATUS_APPROVED lesson end