Fix bad dialog when you have test drive already

This commit is contained in:
Seth Call 2016-04-25 10:15:23 -05:00
parent c7ca2ca974
commit f8c62631f6
6 changed files with 332 additions and 6 deletions

View File

@ -161,7 +161,7 @@
if(options.buttons) {
context._.each(options.buttons, function(button, i) {
if(!button.name) throw "button.name must be specified";
if(!button.click && !button.href) throw "button.click or button.href must be specified";
//if(!button.click && !button.href) throw "button.click or button.href must be specified";
var buttonStyle = button.buttonStyle;
if(!buttonStyle) {

View File

@ -408,7 +408,7 @@ UserStore = context.UserStore
<div className="field date">
<label>Day:</label>
<select className="day_of_week" data-slot="1">{days}</select>
<select name="day-of-week-1" className="day_of_week" data-slot="1">{days}</select>
</div>
<div className="field time">
<label>Time:</label>
@ -422,7 +422,7 @@ UserStore = context.UserStore
<div className="field date">
<label>Day:</label>
<select className="day_of_week" data-slot="2">{days}</select>
<select name="day-of-week-2" className="day_of_week" data-slot="2">{days}</select>
</div>
<div className="field time">
<label>Time:</label>

View File

@ -147,8 +147,8 @@ ProfileActions = @ProfileActions
if response.remaining_test_drives > 0
buttons = []
buttons.push({name: 'CANCEL', buttonStyle: 'button-grey'})
buttons.push({name: 'PAY NORMALLY', buttonStyle: 'button-orange', click:(() => ( window.location.herf = '/client#/jamclass/book-lesson/normal_' + user.id ))})
buttons.push({name: 'USE TEST DRIVE', buttonStyle: 'button-orange', click:(() => ( window.location.herf = '/client#/jamclass/book-lesson/test-drive_' + user.id ))})
buttons.push({name: 'PAY NORMALLY', buttonStyle: 'button-orange', click:(() => ( window.location.href = '/client#/jamclass/book-lesson/normal_' + user.id ))})
buttons.push({name: 'USE TEST DRIVE', buttonStyle: 'button-orange', click:(() => ( window.location.href = '/client#/jamclass/book-lesson/test-drive_' + user.id ))})
context.JK.Banner.show({title: 'You still have TestDrive Credits!', html: "You have #{response.remaining_test_drives} TestDrive credits remaining. Would you rather use your TestDrive credit for a lesson with this teacher?", buttons: buttons})
else
window.location.href = '/client#/jamclass/book-lesson/normal_' + user.id

View File

@ -0,0 +1,162 @@
require 'spec_helper'
describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capybara_feature => true do
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, 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
Recording.delete_all
Diagnostic.delete_all
User.delete_all
UserMailer.deliveries.clear
emulate_client
sign_in_poltergeist user
teacher_user.teacher.ready_for_session_at = Time.now
teacher_user.teacher.save!
teacher_user.teacher.price_per_lesson_60_cents.should eql 3000
Teacher.index(user, {})[:query].count.should eql 1
end
def finish_lesson_successfully
end
describe "register via showing interesting in teacher 1st" do
after(:each) do
Timecop.return
end
it "succeeds" do
visit "/client#/teachers/search"
Timecop.travel(Date.new(2016, 04, 01))
find('.teacher-search-result[data-teacher-id="' + teacher_user.id + '"] .try-normal').trigger(:click)
# switch to recurring
find(".lesson-frequency-recurring ins", visible: false).trigger(:click)
# book the lesson
select "Monday", from: "day-of-week-1"
select "Tuesday", from: "day-of-week-2"
fill_in 'user-description', with: 'abc def dog neck'
select('60 Minute Lesson Each Week - $30.00 Per Month', :from => "booking-options-for-teacher")
sleep 3
find('a.book-lesson-btn', text: 'BOOK LESSON').trigger(:click)
find('h2', text: 'enter payment info for lesson')
user.student_lesson_bookings.count.should eql 1
lesson_booking = user.student_lesson_bookings.first
lesson_booking.is_requested?.should be_true
lesson_booking.card_presumed_ok.should be_false
lesson_booking.recurring.should be true
lesson_booking.is_monthly_payment?.should be true
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)
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_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
# 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 lesson 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)
# switch back to single
find(".lesson-frequency-single ins", visible: false).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_booking.recurring.should be false
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
end
end

View File

@ -0,0 +1,163 @@
require 'spec_helper'
describe "Book Single Recurring Lesson", :js => true, :type => :feature, :capybara_feature => true do
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, 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
Recording.delete_all
Diagnostic.delete_all
User.delete_all
UserMailer.deliveries.clear
emulate_client
sign_in_poltergeist user
teacher_user.teacher.ready_for_session_at = Time.now
teacher_user.teacher.save!
teacher_user.teacher.price_per_lesson_60_cents.should eql 3000
Teacher.index(user, {})[:query].count.should eql 1
end
def finish_lesson_successfully
end
describe "register via showing interesting in teacher 1st" do
after(:each) do
Timecop.return
end
it "succeeds" do
visit "/client#/teachers/search"
Timecop.travel(Date.new(2016, 04, 01))
find('.teacher-search-result[data-teacher-id="' + teacher_user.id + '"] .try-normal').trigger(:click)
# switch to recurring
find(".lesson-frequency-recurring ins", visible: false).trigger(:click)
# book the lesson
select "Monday", from: "day-of-week-1"
select "Tuesday", from: "day-of-week-2"
fill_in 'user-description', with: 'abc def dog neck'
select('60 Minute Lesson Each Week - $30.00 Per Week', :from => "booking-options-for-teacher")
sleep 3
find('a.book-lesson-btn', text: 'BOOK LESSON').trigger(:click)
find('h2', text: 'enter payment info for lesson')
user.student_lesson_bookings.count.should eql 1
lesson_booking = user.student_lesson_bookings.first
lesson_booking.is_requested?.should be_true
lesson_booking.card_presumed_ok.should be_false
lesson_booking.recurring.should be true
lesson_booking.is_monthly_payment?.should be false
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)
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_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
# 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 lesson 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)
# switch back to single
find(".lesson-frequency-single ins", visible: false).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_booking.recurring.should be false
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
end
end

View File

@ -72,6 +72,7 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
lesson_booking = user.student_lesson_bookings.first
lesson_booking.is_requested?.should be_true
lesson_booking.card_presumed_ok.should be_false
lesson_booking.recurring.should be false
@ -113,7 +114,7 @@ describe "Single Lesson", :js => true, :type => :feature, :capybara_feature => t
# let's make a second request to a different teacher now
# let's make sure we can ask for another test drive too!
# let's make sure we can ask for another lesson too!
teacher_user2.teacher.ready_for_session_at = Time.now
teacher_user2.teacher.save!