VRFS-4142 - works with logged in user

This commit is contained in:
Seth Call 2016-06-03 09:45:11 -05:00
parent d2f478395e
commit c6b11e64ad
3 changed files with 55 additions and 7 deletions

View File

@ -164,11 +164,22 @@ rest = context.JK.Rest()
test_drive_package.name = @props.package.name
test_drive_package.teachers = teachers
test_drive_package
markStudent: () ->
rest.updateUser({student: true})
test_drive_package = @createTestDriveData()
rest.updateUser({student: true, test_drive_package: test_drive_package})
.done((response) =>
this.setState({done: true})
context.location = '/client#/jamclass/searchOptions'
if test_drive_package?
choice = response.test_drive_package_choices?[0]
if choice?
context.location = '/client#/jamclass/lesson-payment/package_' + choice.id
else
context.location = '/client#/jamclass/searchOptions'
else
context.location = '/client#/jamclass/searchOptions'
)
.fail((jqXHR) =>
this.setState({processing: false})

View File

@ -180,7 +180,12 @@ class ApiUsersController < ApiController
@user.is_a_teacher = params[:teacher] if params.has_key?(:teacher)
@user.school_interest = !!params[:school_interest]
@user.desired_package = LessonPackageType.find_by_package_type!(params[:desired_package]) if params.has_key?(:desired_package)
@user.save
if @user.save
test_drive_package_details = params[:test_drive_package]
test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) if test_drive_package_details
@user.handle_test_drive_package(test_drive_package, test_drive_package_details) if test_drive_package
end
if @user.errors.any?
respond_with @user, :status => :unprocessable_entity

View File

@ -89,6 +89,39 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
user.musician.should be true
end
it "logged in with 4-pack" do
package = FactoryGirl.create(:test_drive_package, :four_pack)
fast_signin(user, "/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')
find('p', text: 'Like the TestDrive concept, but 4 teachers is too many for you?')
find('button.cta-button', text: 'TRY TESTDRIVE').trigger(:click)
package.test_drive_package_teachers.each do |package_teacher|
teacher = package_teacher.user
find('.teacher-name-packaged', text: teacher.last_name)
end
user.reload
user.is_a_student.should be true
user.is_a_teacher.should be false
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 4
fill_out_payment
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)
end
it "4-count package, user picks 2" do
package = FactoryGirl.create(:test_drive_package, :four_pack)
@ -208,7 +241,7 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
it "2-count package, user picks 1" do
package = FactoryGirl.create(:test_drive_package, :one_pack)
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')
@ -284,12 +317,11 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
find('#banner .close-btn').trigger(:click)
user = User.find_by_email('student_package4@jamkazam.com')
user = User.find_by_email('student_package5@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
@ -297,7 +329,7 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
user.student_lesson_bookings.count.should eql 1
foundTeacher1 = false
user.student_lesson_bookings.each do |booking|
if booking.teacher == teacher2
if booking.teacher == teacher1
foundTeacher1 = true
end
end