ready for release JamClass

This commit is contained in:
Seth Call 2016-05-31 08:35:04 -05:00
parent 55a53325dd
commit e8843bfd64
15 changed files with 80 additions and 47 deletions

View File

@ -796,11 +796,12 @@ module JamRuby
self.countered_slot = slot
self.countered_lesson = self
self.status = STATUS_COUNTERED
if !update_all
#if !update_all
self.counter_slot = slot
end
#end
if self.save
if update_all && !lesson_booking.counter(self, proposer, slot)
#if update_all && !lesson_booking.counter(self, proposer, slot)
if !lesson_booking.counter(self, proposer, slot)
response = lesson_booking
raise ActiveRecord::Rollback
end

View File

@ -42,7 +42,6 @@ describe "Monthly Recurring Lesson Flow" do
########## Need validate their credit card
token = create_stripe_token
result = user.payment_update({token: token, zip: '78759', normal: true, booking_id: booking.id})
puts "result #{result.inspect}"
booking.reload
booking.card_presumed_ok.should be_true
booking.errors.any?.should be_false
@ -118,7 +117,7 @@ describe "Monthly Recurring Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false, accepter: teacher_user})
UserMailer.deliveries.each do |del|
# puts del.inspect
end
@ -203,7 +202,7 @@ describe "Monthly Recurring Lesson Flow" do
payment = TeacherPayment.first
payment.amount_in_cents.should eql 3000
payment.fee_in_cents.should eql (3000 * 0.28).round
payment.teacher_payment_charge.amount_in_cents.should eql 3000
payment.teacher_payment_charge.amount_in_cents.should eql (3000 + 3000 * APP_CONFIG.stripe[:ach_pct]).round
payment.teacher_payment_charge.fee_in_cents.should eql (3000 * 0.28).round
payment.teacher.should eql teacher_user
payment.teacher_distribution.should eql teacher_distribution
@ -320,7 +319,7 @@ describe "Monthly Recurring Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false, accepter: teacher_user})
UserMailer.deliveries.each do |del|
# puts del.inspect
end
@ -419,6 +418,7 @@ describe "Monthly Recurring Lesson Flow" do
it "affiliate gets their cut" do
Timecop.travel(2016, 05, 15)
user.affiliate_referral = affiliate_partner
user.save!
teacher_user.affiliate_referral = affiliate_partner2
@ -429,7 +429,6 @@ describe "Monthly Recurring Lesson Flow" do
user.reload
puts "user.lesson_purchases #{user.lesson_purchases}"
user.lesson_purchases.count.should eql 1
lesson_package_purchase = user.lesson_purchases.first
teacher_distribution = lesson_package_purchase.teacher_distribution
@ -447,6 +446,7 @@ describe "Monthly Recurring Lesson Flow" do
end
it "school affiliate gets nothing when teacher school is involved" do
Timecop.travel(2016, 05, 15)
teacher.school = school
teacher.save!
@ -469,6 +469,8 @@ describe "Monthly Recurring Lesson Flow" do
end
it "student school affiliates gets cut when student school is involved. so does teacher's" do
# in the middle of the month so that we don't get the next month's in-advance purchase put on us
Timecop.travel(2016, 05, 15)
user.affiliate_referral = school.affiliate_partner
user.save!

View File

@ -68,7 +68,7 @@ describe "Normal Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: booking.default_slot.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: booking.default_slot.id, update_all: false, accepter: teacher_user})
lesson_session.errors.any?.should be_false
lesson_session.reload
lesson_session.slot.should eql booking.default_slot
@ -251,7 +251,7 @@ describe "Normal Lesson Flow" do
payment = TeacherPayment.first
payment.amount_in_cents.should eql 3000
payment.fee_in_cents.should eql (3000 * 0.28).round
payment.teacher_payment_charge.amount_in_cents.should eql 3000
payment.teacher_payment_charge.amount_in_cents.should eql (3000 + 3000 * APP_CONFIG.stripe[:ach_pct]).round
payment.teacher_payment_charge.fee_in_cents.should eql (3000 * 0.28).round
payment.teacher.should eql teacher_user
payment.teacher_distribution.should eql teacher_distribution
@ -352,7 +352,7 @@ describe "Normal Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false,accepter: teacher_user})
lesson_session.errors.any?.should be_false
lesson_session.reload
lesson_session.slot.should eql student_counter
@ -508,7 +508,7 @@ describe "Normal Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false, accepter: teacher_user})
lesson_session.errors.any?.should be_false
lesson_session.reload
lesson_session.slot.should eql student_counter

View File

@ -105,7 +105,7 @@ describe "Recurring Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false, accepter: teacher_user})
UserMailer.deliveries.each do |del|
# puts del.inspect
end
@ -132,7 +132,8 @@ describe "Recurring Lesson Flow" do
notification.student_directed.should eql true
notification.purpose.should eql 'accept'
notification.description.should eql NotificationTypes::LESSON_MESSAGE
user.reload
user.sales.length.should eql 0
# teacher & student get into session
start = lesson_session.scheduled_start
@ -181,6 +182,9 @@ describe "Recurring Lesson Flow" do
lesson_session.sent_billing_notices.should be true
user.reload
user.remaining_test_drives.should eql 0
UserMailer.deliveries.each do |d|
puts d.subject
end
UserMailer.deliveries.length.should eql 2 # one for student, one for teacher
end
end

View File

@ -140,7 +140,7 @@ describe "TestDrive Lesson Flow" do
######## Teacher accepts slot
UserMailer.deliveries.clear
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false})
lesson_session.accept({message: 'Yeah I got this', slot: student_counter.id, update_all: false, accepter: teacher_user})
lesson_session.errors.any?.should be_false
lesson_session.reload
lesson_session.slot.should eql student_counter
@ -237,7 +237,7 @@ describe "TestDrive Lesson Flow" do
teacher_distribution.ready.should be_true
teacher_distribution.distributed.should be_true
teacher_payment.teacher_payment_charge.amount_in_cents.should eql 1000
teacher_payment.teacher_payment_charge.amount_in_cents.should eql (1000 + 1000 * APP_CONFIG.stripe[:ach_pct]).round
teacher_payment.teacher_payment_charge.fee_in_cents.should eql 0
user.sales.count.should eql 1

View File

@ -10,6 +10,14 @@ describe LessonSession do
let(:lesson_booking) {b = LessonBooking.book_normal(user, teacher, [slot1, slot2], "Hey I've heard of you before.", false, LessonBooking::PAYMENT_STYLE_SINGLE, 60); b.card_presumed_ok = true; b.save!; b}
let(:lesson_session) {lesson_booking.lesson_sessions[0]}
describe "counter" do
describe "recurring" do
it "" do
end
end
end
describe "autocancel" do
it "can't autocancel in the past" do
lesson_session.status.should eql LessonSession::STATUS_REQUESTED

View File

@ -65,7 +65,6 @@ def book_lesson(user, teacher, options)
LessonPackagePurchase.create(user, booking, LessonPackageType.package_for_test_drive_count(options[:package_count]))
end
elsif options[:monthly]
puts "did it"
LessonPackagePurchase.create(user, booking, LessonPackageType.single, Date.today.year, Date.today.month)
end

View File

@ -99,6 +99,10 @@
ioTargetFail : 'ioTargetFail'
}
var jamClassReasons = {
testDrive: 'TestDrive'
}
var networkTestFailReasons = {
stun : 'STUN',
bandwidth : 'Bandwidth',
@ -129,7 +133,8 @@
jkFollow : 'jkFollow',
jkFavorite : 'jkFavorite',
jkComment : 'jkComment',
fileDownload: "DownloadFile"
fileDownload: "DownloadFile",
jamclass: 'JamClass'
};
// JamTrack categories and actions:
@ -204,6 +209,11 @@
context.ga('send', 'event', categories.register, action, registrationType);
}
function trackTestDrivePurchase(count) {
context.ga('send', 'event', categories.jamclass, jamClassReasons.testDrive, count);
}
function trackDownload(platform) {
var normalizedPlatform = translatePlatformForGA(platform);
@ -490,6 +500,7 @@
GA.virtualPageView = virtualPageView;
GA.trackTiming = trackTiming;
GA.trackFileDownload = trackFileDownload;
GA.trackTestDrivePurchase = trackTestDrivePurchase;
context.JK.GA = GA;

View File

@ -172,10 +172,10 @@ UserStore = context.UserStore
if booking.counter_slot?
startSlotDecision = booking.counter_slot.id
else
if booking.accepter_id?
startSlotDecision = 'counter'
else
startSlotDecision = booking.default_slot.id
if booking.accepter_id?
startSlotDecision = 'counter'
else
startSlotDecision = booking.default_slot.id
update_all = !booking.focused_lesson?.id?
@ -189,10 +189,11 @@ UserStore = context.UserStore
@processBooking(booking)
#if booking.onlyOptions
if booking.onlyOption
# you see two options (accept, and propose new) if it's a counter and you are not the last to act
# the only choice possible in most cases is to propose a new time
# nextState.slot_decision = 'counter'
#nextState.slot_decision = 'counter'
startSlotDecision = 'counter'
@setState({booking: booking, updating: false, slot_decision: startSlotDecision, updatingLesson: false, update_all: update_all})
getLessonBookingDone: (response) ->

View File

@ -294,6 +294,12 @@ UserStore = context.UserStore
logger.debug("testDriveCount: " + testDriveCount)
testDriveCountInt = parseInt(testDriveCount);
if context._.isNaN(testDriveCountInt)
testDriveCountInt = 3
context.JK.GA.trackTestDrivePurchase(testDriveCountInt);
if response.test_drive?.teacher_id
teacher_id = response.test_drive.teacher_id
if testDriveCount == '1'

View File

@ -23,7 +23,7 @@ teacherActions = window.JK.Actions.Teacher
lesson.isAdmin = context.JK.currentUserAdmin
lesson.schoolOnSchool = lesson['school_on_school?']
lesson.cardNotOk = !lesson.schoolOnSchool && !lesson.lesson_booking.card_presumed_ok
lesson.isActive = lesson['is_active?']
if (lesson.status == 'requested' || lesson.status == 'countered')
lesson.isRequested = true
if lesson.cardNotOk

View File

@ -76,7 +76,8 @@
$('.like-link').click(function() {
var like_site = $(this).data('site');
JK.GA.trackJKSocial(JK.GA.Categories.jkLike, like_site, JK.clientType());
// removed because we are juggling 20 events max in GA
//JK.GA.trackJKSocial(JK.GA.Categories.jkLike, like_site, JK.clientType());
window.open("/endorse/0/"+like_site, '_blank');
});
}

View File

@ -380,7 +380,8 @@ class UsersController < ApplicationController
js =<<JS
<script type="text/javascript">
$(function() {
JK.GA.trackJKSocial(JK.GA.Categories.jkLike, '#{service}', 'email');
// // removed because we are juggling 20 events max in GA
// JK.GA.trackJKSocial(JK.GA.Categories.jkLike, '#{service}', 'email');
window.location = "#{url}";
});
</script>

View File

@ -14,25 +14,7 @@ script type='text/template' id='template-lesson-session-actions'
li data-lesson-option="attach-audio"
a href='#' Attach Audio File
= '{% } else if (data.isRequested) { %}'
ul
li data-lesson-option="status"
a href='#' View Status
li data-lesson-option="messages"
a href='#' View Messages
li data-lesson-option="messages"
a href='#' Attach Message
li data-lesson-option="cancel"
= '{% if (data.isStudent) { %}'
a href='#' Cancel Request
= '{% } else { %}'
a href='#' Decline Request
= '{% } %}'
= '{% } else if (data.isScheduled) { %}'
= '{% } else if (data.isActive) { %}'
ul
li data-lesson-option="status"
a href='#' View Status
@ -67,6 +49,23 @@ script type='text/template' id='template-lesson-session-actions'
li data-lesson-option="start-65-ago"
a href='#' Set Start 65 Min Ago
= '{% } %}'
= '{% } else if (data.isRequested) { %}'
ul
li data-lesson-option="status"
a href='#' View Status
li data-lesson-option="messages"
a href='#' View Messages
li data-lesson-option="messages"
a href='#' Attach Message
li data-lesson-option="cancel"
= '{% if (data.isStudent) { %}'
a href='#' Cancel Request
= '{% } else { %}'
a href='#' Decline Request
= '{% } %}'
= '{% } else { %}'
ul

View File

@ -49,7 +49,7 @@ describe "Test Drive", :js => true, :type => :feature, :capybara_feature => true
# we tell user they have test drive purchased, and take them to the teacher screen
find('#banner h1', text: 'Test Drive Purchased')
find('#banner .dialog-inner', text: "You have purchased #{4} TestDrive credits and have used 1 credit it to request a JamClass with #{teacher_user.name}")
find('#banner .dialog-inner', text: "You have purchased #{4} TestDrive credits and have used 1 credit to request a JamClass with #{teacher_user.name}")
# dismiss banner
find('a.button-orange', text:'CLOSE').trigger(:click)