Better tests

This commit is contained in:
Seth Call 2016-04-25 08:09:00 -05:00
parent a14b58f2fe
commit 872bcd2582
2 changed files with 68 additions and 7 deletions

View File

@ -228,7 +228,10 @@ UserStore = context.UserStore
@setState({updating: false})
UserActions.refresh()
if response.user['has_stored_credit_card?']
context.location = "/client#/jamclass/lesson-booking/#{response.id}"
context.JK.Banner.showNotice("Lesson Requested","The teacher has been notified of your lesson request, and should respond soon.<br/><br/>We've taken you automatically to the page for this request, and sent an email to you with a link here as well. All communication with the teacher will show up on this page and in email.")
url = "/client#/jamclass/lesson-booking/#{response.id}"
url = "/client#/jamclass"
context.location = url
else
context.location = "/client#/jamclass/lesson-payment/lesson-booking_#{response.id}"

View File

@ -5,7 +5,9 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
subject { page }
let(:user) { FactoryGirl.create(:user, traditional_band: true,paid_sessions: true, paid_sessions_hourly_rate: 1, paid_sessions_daily_rate:1 ) }
let(:teacher_user) {FactoryGirl.create(:teacher_user, ready_for_session_at: Time.now)}
let(:teacher_user) {FactoryGirl.create(:teacher_user, first_name: "Teacher1", ready_for_session_at: Time.now)}
let(:teacher_user2) {FactoryGirl.create(:teacher_user, ready_for_session_at: Time.now)}
before(:each) do
LessonBooking.destroy_all
@ -84,21 +86,77 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
find('#banner h1', text: 'Lesson Requested')
# dismiss banner
find('a.button-orange', text:'CLOSE').trigger(:click)
lesson_booking = LessonBooking.where(teacher_id: teacher_user).first
lesson_booking.should_not be_nil
lesson_session = LessonSession.where(teacher_id: teacher_user).first
lesson_session.teacher.should eql teacher_user
lesson_session = LessonSession.order('created_at desc').first
# validate that we made a lesson purchase
lesson_package_purchase = LessonPackagePurchase.where(user_id: user.id).first
lesson_package_purchase.should be_nil
user.reload
user.remaining_test_drives.should eql 0
#lesson_package_purchase.amount_charged.should eql 49.99
user.sales.count.should eql 0
# the spec says take them back to search; there is some wasted effort here by the student; they have to click the teacher 2x. Ok?
# jamclass scren
find('h2', text: 'my lessons')
find('tr[data-lesson-session-id="' + lesson_session.id + '"] .displayStatusColumn', text: 'Requested')
find('tr[data-lesson-session-id="' + lesson_session.id + '"] .first_name', text: teacher_user.first_name)
# open up hover
find('tr[data-lesson-session-id="' + lesson_session.id + '"] .lesson-session-actions-btn').trigger(:click)
# check out the status
find('li[data-lesson-option="status"] a', text: 'View Status').trigger(:click)
# and now go to the session status screen
find('h2', text: 'your lesson has been requested')
# let's make a second request to a different teacher now
# let's make sure we can ask for another test drive too!
teacher_user2.teacher.ready_for_session_at = Time.now
teacher_user2.teacher.save!
visit "/client#/teachers/search"
find('a.teacher-search-options').trigger(:click)
find('a.search-btn').trigger(:click)
find('.teacher-search-result[data-teacher-id="' + teacher_user2.id + '"] .try-normal').trigger(:click)
# book the lesson
fill_in "slot-1-date", with: "Sun Apr 17 2016"
#find('.slot.slot-1 input.hasDatepicker').trigger(:click)
# click 4-6
find('td a', text: '17').trigger(:click)
#find('.slot.slot-2 input.hasDatepicker').trigger(:click)
# click 4-7
fill_in "slot-2-date", with: "Mon Apr 18 2016"
find('td a', text: '18').trigger(:click)
fill_in 'user-description', with: 'abc def dog neck'
select('60 Minute Lesson for $30.00', :from => "booking-options-for-teacher")
sleep 3
find('a.book-lesson-btn', text: 'BOOK LESSON').trigger(:click)
# we tell user they have test drive purchased, and take them to the teacher screen
find('#banner h1', text: 'Lesson Requested')
# dismiss banner
find('a.button-orange', text:'CLOSE').trigger(:click)
lesson_booking = LessonBooking.where(teacher_id: teacher_user2).first
lesson_booking.should_not be_nil
lesson_session = LessonSession.where(teacher_id: teacher_user2).first
lesson_session.teacher.should eql teacher_user2
lesson_package_purchase = LessonPackagePurchase.where(user_id: user.id).first
lesson_package_purchase.should be_nil
user.reload
user.remaining_test_drives.should eql 0
user.sales.count.should eql 0
finish_lesson_successfully
end