VRFS-4142 - a few fixes for test drive packages

This commit is contained in:
Seth Call 2016-06-03 08:06:47 -05:00
parent 88ebada41c
commit 8b8aa08ac0
7 changed files with 47 additions and 11 deletions

View File

@ -13,9 +13,7 @@ module JamRuby
#validate :teacher_count
def lesson_package_type
LessonPackageType.package_for_test_drive_count(package_type.to_i)
end
def teacher_count
if package_type != test_drive_package_teachers.length
self.errors.add(:test_drive_package_teachers, "wrong number of teachers specified for the given package type #{package_type}")

View File

@ -9,5 +9,9 @@ module JamRuby
has_many :test_drive_package_choice_teachers, class_name: "JamRuby::TestDrivePackageChoiceTeacher", inverse_of: :test_drive_package_choice
has_many :lesson_bookings, class_name: "JamRuby::LessonBooking"
end
def lesson_package_type
LessonPackageType.package_for_test_drive_count(test_drive_package_choice_teachers.count)
end
end

View File

@ -2088,7 +2088,7 @@ module JamRuby
if booking
lesson_package_type = booking.resolved_test_drive_package
elsif choice
choice.test_drive_package.lesson_package_type
lesson_package_type = choice.lesson_package_type
end
if lesson_package_type.nil?

View File

@ -26,7 +26,6 @@
window.JK.app.layout.showDialog('test-drive-package-dialog', {d1: count.toString()}).one(window.JK.EVENTS.DIALOG_CLOSED, (e, data) =>
#... code
if !data.canceled
console.log("dialog closed. result", data)
# dialog wasn't cancelled, so let's check the value of our result:
@setState(data.result)
@setState({modified: true})

View File

@ -172,10 +172,10 @@ rest = context.JK.Rest()
test_drive_package = null
if @props.package
if @props.package?
test_drive_package ={}
if window.teacherModifications?
teachers = window.window.teacherModifications
teachers = window.teacherModifications
else
teachers = @props.package.teachers
test_drive_package.name = @props.package.name

View File

@ -89,7 +89,7 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
user.musician.should be true
end
it "package 4 count but picks 2" do
it "4-count package, user picks 2" do
package = FactoryGirl.create(:test_drive_package, :four_pack)
visit "/landing/jamclass/students?utm-teachers=#{package.name}"
@ -119,6 +119,37 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
page.should_not have_selector('.teacher-name-packaged', text: teacher4.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_package2@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 "package 4 count" do
@ -190,8 +221,13 @@ 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: 'will take place this')
find('.generic-time-stmt', text: 'proposed alternate day/time is')
approve_lesson(lesson)
validate_status(lesson, 'Scheduled')
jamclass_hover_option(lesson, 'status', 'View Status')
find('.generic-time-stmt', text: 'will take place this')
end
end

View File

@ -212,8 +212,7 @@ def sign_out_poltergeist(options = {})
end
def open_user_dropdown
#find('.userinfo').hover()
find('.userinfo').mousemove()
find('.userinfo').hover()
end