VRFS-4091 VRFS-4089 VRFS-4088 - test drive payment screen is correct now, student can always join session

This commit is contained in:
Seth Call 2016-05-20 10:31:43 -05:00
parent 6652808f86
commit 7737f0977e
9 changed files with 85 additions and 41 deletions

View File

@ -109,13 +109,13 @@ module JamRuby
if music_session.musician_access
if music_session.approval_required
unless music_session.creator == user || music_session.invited_musicians.exists?(user)
if !(music_session.music_session.creator == user || music_session.creator == user || music_session.invited_musicians.exists?(user))
errors.add(:approval_required, ValidationMessages::INVITE_REQUIRED)
return false
end
end
else
unless music_session.creator == user || music_session.invited_musicians.exists?(user)
if !(music_session.music_session.creator == user || music_session.creator == user || music_session.invited_musicians.exists?(user))
errors.add(:musician_access, ValidationMessages::INVITE_REQUIRED)
return false
end

View File

@ -17,6 +17,22 @@ describe LessonSession do
end
end
describe "permissions" do
it "student can join session" do
lesson = normal_lesson(user, teacher)
FactoryGirl.create(:active_music_session, music_session: lesson.music_session, creator: teacher)
connection1 = FactoryGirl.create(:connection, user: user, music_session_id: lesson.music_session.active_music_session.id, as_musician: true)
connection2 = FactoryGirl.create(:connection, user: teacher, music_session_id: lesson.music_session.active_music_session.id, as_musician: true)
connection1.can_join_music_session
connection1.errors.any?.should be_false
connection2.can_join_music_session
connection2.errors.any?.should be_false
end
end
describe "upcoming_sessions_reminder" do
it "succeeds" do
lesson = normal_lesson(user, teacher)

View File

@ -285,7 +285,11 @@ LessonTimerActions = context.LessonTimerActions
@updateLessonState(lesson_session)
@app.layout.showDialog('chat-dialog', {d1: 'lesson_' + lesson_session.id})
# if this is a not-confirmed lesson, send them to the view statu screen
if lesson_session.isRequested
window.location.href = '/client#/jamclass/lesson-booking/' + lesson.id
else
@app.layout.showDialog('chat-dialog', {d1: 'lesson_' + lesson_session.id})
updatedLessonSessionReadFail: (jqXHR) ->

View File

@ -417,9 +417,17 @@ UserStore = context.UserStore
header = `<div><h2>enter payment info for test drive</h2></div>`
bookingInfo = `<p></p>`
bookingDetail = `<p>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entitles
you to take 4 private online music lessons - 1 each from 4 different instructors in the JamClass instructor
community.
if this.state.user.lesson_package_type_id == 'test-drive'
explanation = `<span>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entitles you to take 4 private online music lessons - 1 each from 4 different instructors in the JamClass instructor community. The price of this TestDrive package is $49.99.</span>`
else if this.state.user.lesson_package_type_id == 'test-drive-1'
explanation =`<span>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entitles you to take 1 private online music lesson from an instructor in the JamClass instructor community. The price of this TestDrive package is $14.99.</span>`
else if this.state.user.lesson_package_type_id == 'test-drive-2'
explanation =`<span>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entitles you to take 2 private online music lessons - 1 each from 2 different instructors in the JamClass instructor community. The price of this TestDrive package is $29.99.</span>`
else
alert("You do not have a test drive package selected")
bookingDetail = `<p>{explanation}
<br/>
<span className="jamclass-policies"><a href="/corp/terms" rel="external" onClick={this.jamclassPolicies}>jamclass

View File

@ -55,10 +55,16 @@ SampleApp::Application.configure do
config.websocket_gateway_port = 6759
config.websocket_gateway_uri = "ws://localhost:#{config.websocket_gateway_port}/websocket"
config.websocket_gateway_connect_time_stale_client = 4
config.websocket_gateway_connect_time_expire_client = 6
config.websocket_gateway_connect_time_stale_browser = 4
config.websocket_gateway_connect_time_expire_browser = 6
#config.websocket_gateway_connect_time_stale_client = 4
#config.websocket_gateway_connect_time_expire_client = 6
#config.websocket_gateway_connect_time_stale_browser = 4
#config.websocket_gateway_connect_time_expire_browser = 6
config.websocket_gateway_connect_time_stale_client = 80
config.websocket_gateway_connect_time_expire_client = 120
config.websocket_gateway_connect_time_stale_browser = 80
config.websocket_gateway_connect_time_expire_browser = 120
# this is totally awful and silly; the reason this exists is so that if you upload an artifact
# through jam-admin, then jam-web can point users at it. I think 99% of devs won't even see or care about this config, and 0% of users

View File

@ -35,7 +35,7 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
after(:each) do
Timecop.return
end
it "succeeds" do
it "succeeds normal" do
Timecop.travel(Date.new(2016, 03, 01))
testdrive_lesson(user, teacher_user3)
@ -43,6 +43,10 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
user.save!
user.reload
# the testdrive_lesson helper fakes out a credit card, but we need to stop faking and let the web UI drive us into the payment form
user.stored_credit_card = false
user.save!
sign_in_poltergeist user
visit "/client#/teachers/search"
@ -69,23 +73,15 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
find('a.book-lesson-btn', text: 'BOOK LESSON').trigger(:click)
#find('h2', text: 'your lesson has been requested')
#find('h2', text: 'enter payment info for lesson')
#fill_in 'card-number', with: '4111111111111111'
#fill_in 'expiration', with: '11/2016'
#fill_in 'cvv', with: '111'
#fill_in 'zip', with: '78759'
#find('.purchase-btn').trigger(:click)
fill_out_payment('Your card will not be charged until the day of the lesson.')
# 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)
user.reload
user.stripe_customer_id.should_not be_nil
user.student_lesson_bookings.count.should eql 2 # this single one, and the test drive created in the before section of the test
lesson_booking = user.student_lesson_bookings.order(:created_at).last
lesson_booking.is_requested?.should be_true
@ -181,6 +177,8 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
analysis["reason"].should eql LessonSessionAnalyser::SUCCESS
lesson_session1.success.should be_true
lesson_session1.billing_attempts.should eql 1
puts lesson_session1.billing_error_reason
puts lesson_session1.billing_error_detail
lesson_session1.billed.should eql true
LessonBooking.hourly_check
@ -221,6 +219,10 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
user.school = school
user.save!
# the testdrive_lesson helper fakes out a credit card, but we need to stop faking and let the web UI drive us into the payment form
user.stored_credit_card = false
user.save!
sign_in_poltergeist user
visit "/client#/teachers/search"
@ -247,23 +249,12 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
find('a.book-lesson-btn', text: 'BOOK LESSON').trigger(:click)
#find('h2', text: 'your lesson has been requested')
#find('h2', text: 'enter payment info for lesson')
#fill_in 'card-number', with: '4111111111111111'
#fill_in 'expiration', with: '11/2016'
#fill_in 'cvv', with: '111'
#fill_in 'zip', with: '78759'
#find('.purchase-btn').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)
user.student_lesson_bookings.count.should eql 1 # this single one
lesson_booking = user.student_lesson_bookings.order(:created_at).last
lesson_booking.is_requested?.should be_true
@ -306,18 +297,18 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
teacher_user2.teacher.save!
visit "/client#/teachers/search"
find('span.search-summary', text: 'my school teachers only')
find('span.search-summary', text: 'From My School Only')
find('a.teacher-search-options').trigger(:click)
find('input.onlyMySchool').trigger(:click) # uncheck
find('a.search-btn').trigger(:click)
find('span.search-summary', text: 'all teachers')
find('.teacher-search-result[data-teacher-id="' + teacher_user2.id + '"] .try-test-drive').trigger(:click)
select_test_drive(4)
select_test_drive(2)
fill_out_single_lesson
fill_out_payment
fill_out_payment('This purchase entitles you to take 2 private online music')
sleep 5
@ -338,9 +329,14 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
lesson_package_purchase = LessonPackagePurchase.where(user_id: user.id, teacher_id: teacher_user.id).order(:created_at).first
lesson_package_purchase.should be_nil
user.reload
user.remaining_test_drives.should eql 3
user.remaining_test_drives.should eql 1
user.sales.count.should eql 1
bookings = LessonBooking.where(teacher_id: lesson_session.teacher.id)
bookings.each do |b|
puts "BOOKING: #{b.inspect}"
end
# approve by teacher:
teacher_approve(lesson_session1)

View File

@ -45,7 +45,7 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true
fill_out_single_lesson
fill_out_payment
fill_out_payment('This purchase entitles you to take 4 private online music')
# we tell user they have test drive purchased, and take them to the teacher screen
find('#banner h1', text: 'Test Drive Purchased')

View File

@ -36,6 +36,9 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true
fast_signin(user, "/client#/jamclass")
find('#jam-class-student-screen td.displayStatusColumn', text: 'Missed (Teacher)')
# also check that clicking messages icon shows chat dialog (instead of view status screen) # VRFS-4089
find('tr[data-lesson-session-id="' + lesson.id + '"] a.unreadColumn').trigger(:click)
find('h1', text: 'respond to lesson request')
end
it "shows Completed" do
@ -58,12 +61,20 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true
find('tr[data-lesson-session-id="' + lesson.id + '"] .lesson-session-actions-btn').trigger(:click)
find('li[data-lesson-option="cancel"] a', visible: false, text: 'Decline Request')
sign_out_poltergeist
sleep 4
fast_signin(user, "/client#/jamclass")
# also check that clicking messages icon shows view status screen (instead of chat dialog) # VRFS-4089
find('tr[data-lesson-session-id="' + lesson.id + '"] a.unreadColumn').trigger(:click)
find('h2', text: 'respond to lesson request')
find('#jam-class-student-screen td.displayStatusColumn', text: 'Requested')
# open up hover
find('tr[data-lesson-session-id="' + lesson.id + '"] .lesson-session-actions-btn').trigger(:click)
# should work, doesn't

View File

@ -27,7 +27,7 @@ def teacher_approve(lesson_session)
visit "/client#/jamclass/lesson-booking/" + lesson_session.id
find('.schedule.button-orange').trigger(:click)
# dismiss banner
find('a.button-orange', text:'CLOSE').trigger(:click)
#find('a.button-orange', text:'CLOSE').trigger(:click)
find('tr[data-lesson-session-id="' + lesson_session.id + '"] .displayStatusColumn', text: 'Scheduled')
end
@ -56,13 +56,16 @@ def fill_out_single_lesson
end
def fill_out_payment
def fill_out_payment(expected = nil)
fill_in 'card-number', with: '4111111111111111'
fill_in 'expiration', with: '11/2016'
fill_in 'cvv', with: '111'
fill_in 'zip', with: '78759'
if expected
find('.booking-info', text: expected)
end
find('.purchase-btn').trigger(:click)
# it needs to go 'disabled state' to indicate it's updating