diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 3e985fbfc..04fd37f4c 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -1132,7 +1132,7 @@ module JamRuby origin = options[:origin] test_drive_package_details = options[:test_drive_package] - test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) + test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) if test_drive_package_details school = School.find(school_id) if school_id user = User.new diff --git a/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee b/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee index 5d09da185..b67764c09 100644 --- a/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee @@ -1056,7 +1056,7 @@ UserStore = context.UserStore phrase = this.slotTimePhrase(this.counteredSlot()) action = `

Has suggested a different time for your lesson.

` - detail = `

Proposed alternate day/time is {phrase}

` + detail = `

Proposed alternate day/time is {phrase}

` `
diff --git a/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee b/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee index 0c4fd7578..f67403272 100644 --- a/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee @@ -324,7 +324,7 @@ UserStore = context.UserStore if response.test_drive?.teacher_id teacher_id = response.test_drive.teacher_id if testDriveCount == '1' - text = "You have purchased 1 TestDrive credit and have used it to request a JamClass with #{@state.teacher.name}. The teacher has received your request and should respond shortly." + text = "You have purchased 1 TestDrive credit and have used it to request a JamClass with #{@state.package.teachers[0].user.name}. The teacher has received your request and should respond shortly." else if response.package? text = "Each teacher has received your request and should respond shortly." else @@ -433,7 +433,7 @@ UserStore = context.UserStore teachers = [] teachersHolder = [] count = 0 - for teacher_choice in @state.package.teachers + for teacher_choice in @state.package.teachers if count == 2 teachersHolder.push( @@ -487,11 +487,11 @@ UserStore = context.UserStore if this.state.package? if @state.package.teachers.length == 1 - explanation = `You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take a private online music lesson from this instructor. The price of this TestDrive is $14.99. If you have scheduling conflicts with this instructors, we will help you choose another teacher as a replacement.` + explanation = `You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take a private online music lesson from this instructor. The price of this TestDrive is $14.99. If you have scheduling conflicts with this instructors, we will help you choose another teacher as a replacement.` else if @state.package.teachers.length == 2 explanation = `You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 2 private online music lessons - 1 each from these 2 instructors. The price of this TestDrive is $29.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.` else if @state.package.teachers.length == 4 - explanation = `You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 4 private online music lessons - 1 each from these 4 instructors. The price of this TestDrive is $49.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.` + explanation = `You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 4 private online music lessons - 1 each from these 4 instructors. The price of this TestDrive is $49.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.` else alert("unknown package type") else diff --git a/web/app/assets/javascripts/react-components/StripeConnect.js.jsx.coffee b/web/app/assets/javascripts/react-components/StripeConnect.js.jsx.coffee index 0a24142bb..e05dd6d82 100644 --- a/web/app/assets/javascripts/react-components/StripeConnect.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/StripeConnect.js.jsx.coffee @@ -18,6 +18,7 @@ UserStore = context.UserStore return e.preventDefault() + this.setState({clicked: true}) StripeActions.connect(this.props.purpose, this.props.user) diff --git a/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingMiddlePage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingMiddlePage.js.jsx.coffee index 4e87a2c17..7c9779226 100644 --- a/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingMiddlePage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingMiddlePage.js.jsx.coffee @@ -67,7 +67,7 @@

Like the TestDrive concept, but 4 teachers is too many for you?

` @@ -77,7 +77,7 @@

The single most important factor in the success of your music lessons is your teacher. You wouldn't marry the first person you date, right?

-

Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each - a total of +

Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each - a total of $29.99. Then you can pick the one who is best for you to continue your musical journey, with the confidence that your investment in lessons will deliver maximum growth!

` @@ -86,7 +86,7 @@ `

Like the TestDrive concept, but prefer not to try 2 different teachers?

` diff --git a/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingPage.js.jsx.coffee index df48fef61..9d2e98be3 100644 --- a/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/JamClassStudentLandingPage.js.jsx.coffee @@ -153,6 +153,17 @@ rest = context.JK.Rest() @setState({processing: true}) + createTestDriveData: () -> + test_drive_package = null + if @props.package? + test_drive_package ={} + if window.teacherModifications? + teachers = window.teacherModifications + else + teachers = @props.package.teachers + test_drive_package.name = @props.package.name + test_drive_package.teachers = teachers + test_drive_package markStudent: () -> rest.updateUser({student: true}) .done((response) => @@ -170,16 +181,7 @@ rest = context.JK.Rest() password = $form.find('input[name="password"]').val() terms = $form.find('input[name="terms"]').is(':checked') - test_drive_package = null - - if @props.package? - test_drive_package ={} - if window.teacherModifications? - teachers = window.teacherModifications - else - teachers = @props.package.teachers - test_drive_package.name = @props.package.name - test_drive_package.teachers = teachers + test_drive_package = @createTestDriveData() rest.signup({email: email, password: password, first_name: null, last_name: null, terms: terms, student: true, test_drive_package: test_drive_package}) .done((response) => diff --git a/web/spec/features/student_landing_spec.rb b/web/spec/features/student_landing_spec.rb index 4cb74672e..183b8aacd 100644 --- a/web/spec/features/student_landing_spec.rb +++ b/web/spec/features/student_landing_spec.rb @@ -152,6 +152,159 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature => foundTeacher2.should be_true end + it "2-count package, user picks 2" do + + package = FactoryGirl.create(:test_drive_package, :two_pack) + visit "/landing/jamclass/students?utm-teachers=#{package.name}" + + find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher') + find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology') + + teacher1 = package.test_drive_package_teachers[0].user + teacher2 = package.test_drive_package_teachers[1].user + find('p.price-explain', text: 'Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each') + + fill_in "email", with: 'student_package3@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + find('.teacher-name-packaged', text: teacher1.last_name) + find('.teacher-name-packaged', text: teacher2.last_name) + + find('.explanation', text: '2 private online music lessons - 1 each from these 2 instructors') + + fill_out_payment(nil, "Super HahaGuy") + + find('#banner h1', text: 'TestDrive Purchased') + find('#banner .dialog-inner', text: 'Each teacher has received your request and should respond shortly') + find('#banner .close-btn').trigger(:click) + + + user = User.find_by_email('student_package3@jamkazam.com') + user.test_drive_package_choices.count.should eql 1 + choice = user.test_drive_package_choices[0] + choice.test_drive_package_choice_teachers.count.should eql 2 + + + purchase = user.most_recent_test_drive_purchase + purchase.lesson_package_type.is_test_drive?.should be_true + purchase.lesson_package_type.test_drive_count.should eql 2 + + user.student_lesson_bookings.count.should eql 2 + foundTeacher1 = false + foundTeacher2 = false + user.student_lesson_bookings.each do |booking| + if booking.teacher == teacher1 + foundTeacher1 = true + end + if booking.teacher == teacher2 + foundTeacher2 = true + end + end + foundTeacher1.should be_true + foundTeacher2.should be_true + end + + it "2-count package, user picks 1" do + + package = FactoryGirl.create(:test_drive_package, :one_pack) + visit "/landing/jamclass/students?utm-teachers=#{package.name}" + + find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher') + find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology') + + teacher1 = package.test_drive_package_teachers[0].user + teacher2 = package.test_drive_package_teachers[1].user + find('a.pick-one').trigger(:click) + find('input[data-teacher-id="' + teacher2.id + '"]').trigger(:click) + find('a.select-teachers').trigger(:click) + + fill_in "email", with: 'student_package4@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + find('.teacher-name-packaged', text: teacher2.last_name) + + page.should_not have_selector('.teacher-name-packaged', text: teacher1.last_name) + + find('.explanation', text: 'This purchase entities you to take a private online music lesson from this instructor') + + fill_out_payment(nil, "Super HahaGuy") + + find('#banner h1', text: 'TestDrive Purchased') + find('#banner .dialog-inner', text: 'You have purchased 1 TestDrive credit and have used it to request a JamClass with ' + teacher2.name) + find('#banner .close-btn').trigger(:click) + + + user = User.find_by_email('student_package4@jamkazam.com') + user.test_drive_package_choices.count.should eql 1 + choice = user.test_drive_package_choices[0] + choice.test_drive_package_choice_teachers.count.should eql 1 + + + purchase = user.most_recent_test_drive_purchase + purchase.lesson_package_type.is_test_drive?.should be_true + purchase.lesson_package_type.test_drive_count.should eql 1 + + user.student_lesson_bookings.count.should eql 1 + foundTeacher2 = false + user.student_lesson_bookings.each do |booking| + if booking.teacher == teacher2 + foundTeacher2 = true + end + end + foundTeacher2.should be_true + end + + it "1-count package" do + + package = FactoryGirl.create(:test_drive_package, :one_pack) + visit "/landing/jamclass/students?utm-teachers=#{package.name}" + + find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher') + find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology') + + teacher1 = package.test_drive_package_teachers[0].user + + fill_in "email", with: 'student_package5@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + find('.teacher-name-packaged', text: teacher1.last_name) + + find('.explanation', text: 'This purchase entities you to take a private online music lesson from this instructor') + + fill_out_payment(nil, "Super HahaGuy") + + find('#banner h1', text: 'TestDrive Purchased') + find('#banner .dialog-inner', text: 'You have purchased 1 TestDrive credit and have used it to request a JamClass with ' + teacher1.name) + find('#banner .close-btn').trigger(:click) + + + user = User.find_by_email('student_package4@jamkazam.com') + user.test_drive_package_choices.count.should eql 1 + choice = user.test_drive_package_choices[0] + choice.test_drive_package_choice_teachers.count.should eql 1 + + + purchase = user.most_recent_test_drive_purchase + purchase.lesson_package_type.is_test_drive?.should be_true + purchase.lesson_package_type.test_drive_count.should eql 1 + + user.student_lesson_bookings.count.should eql 1 + foundTeacher1 = false + user.student_lesson_bookings.each do |booking| + if booking.teacher == teacher2 + foundTeacher1 = true + end + end + foundTeacher1.should be_true + end + + it "package 4 count" do package = FactoryGirl.create(:test_drive_package, :four_pack) visit "/landing/jamclass/students?utm-teachers=#{package.name}" @@ -221,7 +374,7 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature => switch_user(user, '/client#/jamclass') jamclass_hover_option(lesson, 'status', 'View Status') - find('.generic-time-stmt', text: 'proposed alternate day/time is') + find('.counter-stmt', text: 'Proposed alternate day/time is') approve_lesson(lesson) validate_status(lesson, 'Scheduled')