From f9aec0526da6f5390f6fb8036b4a6f92387831e3 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Fri, 20 May 2016 15:33:44 -0500 Subject: [PATCH] Fix bug where 2nd test drive wouldn't work --- ruby/lib/jam_ruby/models/lesson_package_purchase.rb | 2 ++ ruby/lib/jam_ruby/models/lesson_session.rb | 2 +- ruby/lib/jam_ruby/models/user.rb | 2 +- ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb | 1 + .../LessonBookingDecision.js.jsx.coffee | 2 +- .../react-components/mixins/ICheckMixin.js.coffee | 1 + .../wizard/gear/step_configure_tracks.js | 2 +- .../clients/wizard/gear/_gear_wizard.html.haml | 9 ++++----- web/spec/features/book_test_drive_spec.rb | 13 ++++++++++++- 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ruby/lib/jam_ruby/models/lesson_package_purchase.rb b/ruby/lib/jam_ruby/models/lesson_package_purchase.rb index e9f49da0c..f036572f1 100644 --- a/ruby/lib/jam_ruby/models/lesson_package_purchase.rb +++ b/ruby/lib/jam_ruby/models/lesson_package_purchase.rb @@ -5,6 +5,7 @@ module JamRuby @@log = Logging.logger[LessonPackagePurchase] delegate :sent_billing_notices, :last_billing_attempt_at, :billing_attempts, :billing_should_retry, :billed, :billed_at, :billing_error_detail, :billing_error_reason, :is_card_declined?, :is_card_expired?, :last_billed_at_date, :sent_billing_notices, to: :lesson_payment_charge + delegate :test_drive_count, to: :lesson_package_type # who purchased the lesson package? belongs_to :user, class_name: "JamRuby::User", :foreign_key => "user_id", inverse_of: :lesson_purchases @@ -53,6 +54,7 @@ module JamRuby end + def name lesson_package_type.sale_display end diff --git a/ruby/lib/jam_ruby/models/lesson_session.rb b/ruby/lib/jam_ruby/models/lesson_session.rb index d12bc3ffb..ef8600cd4 100644 --- a/ruby/lib/jam_ruby/models/lesson_session.rb +++ b/ruby/lib/jam_ruby/models/lesson_session.rb @@ -460,7 +460,7 @@ module JamRuby lesson_session.status = booking.status lesson_session.slot = booking.default_slot lesson_session.assigned_student = booking.student - if booking.is_test_drive? + if booking.is_test_drive? && booking.student.remaining_test_drives > 0 lesson_session.lesson_package_purchase = booking.student.most_recent_test_drive_purchase end lesson_session.save diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index f0764e082..b95eb155c 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -2068,7 +2068,7 @@ module JamRuby end def most_recent_test_drive_purchase - lesson_purchases.where('lesson_package_type_id in (?)', [LessonPackageType.test_drive_package_ids]).order('created_at desc').first + lesson_purchases.where('lesson_package_type_id in (?)', LessonPackageType.test_drive_package_ids).order('created_at desc').first end def total_test_drives diff --git a/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb b/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb index 9c2ba33fd..b3c9b47f8 100644 --- a/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb +++ b/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb @@ -242,6 +242,7 @@ describe "TestDrive Lesson Flow" do LessonBooking.engaged_bookings(user, teacher_user, nil).count.should eql 1 teacher_user.has_booked_test_drive_with_student?(user).should be_true + end # VRFS-4069 diff --git a/web/app/assets/javascripts/react-components/LessonBookingDecision.js.jsx.coffee b/web/app/assets/javascripts/react-components/LessonBookingDecision.js.jsx.coffee index f7cd658a2..a2818fafe 100644 --- a/web/app/assets/javascripts/react-components/LessonBookingDecision.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/LessonBookingDecision.js.jsx.coffee @@ -76,7 +76,7 @@ logger.debug("LessonBookingDecision: slot-decision made with value: " + value) - @setState({slot_decision: value}) + @setState({"slot-decision": value}) @props.onSlotDecision({slot_decision: value}) else if name == 'update-all' checked = $(e.target).is(':checked') diff --git a/web/app/assets/javascripts/react-components/mixins/ICheckMixin.js.coffee b/web/app/assets/javascripts/react-components/mixins/ICheckMixin.js.coffee index 0bf3cda13..cc312cb39 100644 --- a/web/app/assets/javascripts/react-components/mixins/ICheckMixin.js.coffee +++ b/web/app/assets/javascripts/react-components/mixins/ICheckMixin.js.coffee @@ -24,6 +24,7 @@ teacherActions = window.JK.Actions.Teacher @iCheckIgnore = true + console.log("CHOICE", choice) if $candidate.attr('type') == 'radio' if choice? $found = @root.find(selector + '[value="' + choice + '"]') diff --git a/web/app/assets/javascripts/wizard/gear/step_configure_tracks.js b/web/app/assets/javascripts/wizard/gear/step_configure_tracks.js index 72e97aad3..07bda374b 100644 --- a/web/app/assets/javascripts/wizard/gear/step_configure_tracks.js +++ b/web/app/assets/javascripts/wizard/gear/step_configure_tracks.js @@ -17,7 +17,7 @@ var wizard = null; function handleHelp() { - return "https://jamkazam.desk.com/customer/portal/articles/1599961-first-time-setup---step-3---configure-tracks"; + return "https://jamkazam.desk.com/customer/en/portal/articles/2400702-using-the-setup-wizard-%E2%80%93-step-3-%E2%80%93-configure-tracks" } function handleNext() { diff --git a/web/app/views/clients/wizard/gear/_gear_wizard.html.haml b/web/app/views/clients/wizard/gear/_gear_wizard.html.haml index 3c9781aad..2f85b2d9e 100644 --- a/web/app/views/clients/wizard/gear/_gear_wizard.html.haml +++ b/web/app/views/clients/wizard/gear/_gear_wizard.html.haml @@ -69,17 +69,16 @@ .wizard-step{ 'layout-wizard-step' => "2", 'dialog-title' => "Configure Tracks", 'dialog-purpose' => "ConfigureTracks" } .ftuesteps .clearall - .help-text In this step, you will select, configure, and test your audio gear. Please watch the video for best instructions. + .help-text In this step, you will set up your live performance audio tracks. .wizard-step-content.no-selection-range .wizard-step-column %h2 Instructions .ftue-box.instructions - Set up one track for each instrument or vocal part you plan to play. For each track: %ul - %li Drag and drop the input port(s) from your audio interface to each track. - %li Select the instrument for each track. + %li Edit the first audio track using the "update" link to set it up as an instrumental or vocal track as you like. + %li If desired, add other audio or MIDI tracks for other instruments or vocals. .center - %a.button-orange.watch-video{href:'https://www.youtube.com/watch?v=SjMeMZpKNR4', rel:'external'} WATCH VIDEO + %a.button-orange.watch-video{href:'https://jamkazam.desk.com/customer/en/portal/articles/2400702-using-the-setup-wizard-%E2%80%93-step-3-%E2%80%93-configure-tracks', rel:'external'} INSTRUCTIONS .wizard-step-column = react_component 'ConfigureTracks', {} diff --git a/web/spec/features/book_test_drive_spec.rb b/web/spec/features/book_test_drive_spec.rb index 670ce87da..631c0bd78 100644 --- a/web/spec/features/book_test_drive_spec.rb +++ b/web/spec/features/book_test_drive_spec.rb @@ -77,7 +77,7 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true lesson_booking.lesson_sessions.count.should eql 1 lesson_session1 = lesson_booking.lesson_sessions.first - + user.most_recent_test_drive_purchase.should_not be_nil # 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! @@ -91,6 +91,17 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true find('h2', text: 'book testdrive lesson') find('.booking-info', text: '3 TestDrive lesson credits') + fill_out_single_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.student_lesson_bookings.count.should eql 2 + lesson_booking2 = user.student_lesson_bookings.order(:created_at).last + lesson_booking2.teacher.should eql teacher_user2 + lesson_booking2.lesson_sessions[0].lesson_package_purchase.should_not be_nil # approve by teacher: teacher_approve(lesson_session1)