diff --git a/ruby/lib/jam_ruby/models/lesson_booking.rb b/ruby/lib/jam_ruby/models/lesson_booking.rb
index 0d69548fc..e270027be 100644
--- a/ruby/lib/jam_ruby/models/lesson_booking.rb
+++ b/ruby/lib/jam_ruby/models/lesson_booking.rb
@@ -243,7 +243,12 @@ module JamRuby
minimum_start_time = create_minimum_booking_time
# get all sessions that are already scheduled for this booking ahead of the minimum time
- sessions = MusicSession.joins(:lesson_session).where("lesson_sessions.lesson_booking_id = ?", id).where("scheduled_start is not null").where("scheduled_start > ?", minimum_start_time).order(:created_at)
+
+ sessions= MusicSession.joins(:lesson_session).where("lesson_sessions.lesson_booking_id = ?", id).where("scheduled_start is not null").order(:created_at)
+ if recurring
+ # only want times ahead of this for recurring
+ sessions = sessions.where("scheduled_start > ?", minimum_start_time)
+ end
if @default_slot_did_change
# # adjust all session times
diff --git a/ruby/spec/jam_ruby/models/lesson_booking_spec.rb b/ruby/spec/jam_ruby/models/lesson_booking_spec.rb
index 4ac09e8ba..fde720cc8 100644
--- a/ruby/spec/jam_ruby/models/lesson_booking_spec.rb
+++ b/ruby/spec/jam_ruby/models/lesson_booking_spec.rb
@@ -753,9 +753,28 @@ describe LessonBooking do
end
describe "rescheduling" do
- after do
- Timecop.return
+ it "initial slot is in the past" do
+ booking = LessonBooking.book_normal(user, teacher_user, valid_single_slots, "Hey I've heard of you before.", false, LessonBooking::PAYMENT_STYLE_SINGLE, 60)
+
+ lesson_session = booking.lesson_sessions[0]
+
+ initial_scheduled_time = lesson_session.scheduled_start
+
+ counter = FactoryGirl.build(:lesson_booking_slot_single, preferred_day: Date.today + 20)
+ lesson_session.counter({proposer: user, slot: counter, message: 'ACtually, let\'s do this instead for just this one'})
+
+ Timecop.travel(initial_scheduled_time + 1)
+
+ lesson_session.accept({accepter: teacher_user, message: 'Yeah I got this', slot: counter, update_all: false})
+ booking.reload
+ booking.status.should eql LessonBooking::STATUS_APPROVED
+ booking.lesson_sessions.count.should eql 1
+ lesson_session.errors.any?.should be_false
+ lesson_session.reload
+ lesson_session.status.should eql LessonSession::STATUS_APPROVED
+ lesson_session.scheduled_start.should eql counter.scheduled_time(0)
end
+
it "non-recurring, accepted with new slot" do
booking = LessonBooking.book_normal(user, teacher_user, valid_single_slots, "Hey I've heard of you before.", false, LessonBooking::PAYMENT_STYLE_SINGLE, 60)
lesson_session = booking.lesson_sessions[0]
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 1202c0e3e..c0ce9c79a 100644
--- a/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/LessonPayment.js.jsx.coffee
@@ -296,16 +296,16 @@ UserStore = context.UserStore
if response.test_drive?.teacher_id
teacher_id = response.test_drive.teacher_id
- if testDriveCount == 1
- text = "You have purchased a TestDrive credit and have used it to request a JamClass with #{@state.teacher.name}. The teacher has received your request and should respond shortly."
+ 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."
else
- text = "You have purchased #{testDriveCount} TestDrive credits and have used 1 credit it to request a JamClass with #{@state.teacher.name}. The teacher has received your request and should respond shortly."
+ text = "You have purchased #{testDriveCount} TestDrive credits and have used 1 credit to request a JamClass with #{@state.teacher.name}. The teacher has received your request and should respond shortly."
location = "/client#/jamclass"
else
if @state.teacher?.id
# the user bought the testdrive, and there is a teacher of interest in context (but no booking)
- if testDriveCount == 1
+ if testDriveCount == '1'
text = "You now have 1 TestDrive credit.
We've taken you to the lesson booking screen for the teacher you initially showed interest in."
location = "/client#/jamclass/book-lesson/test-drive_" + teacher_id
else
@@ -313,7 +313,7 @@ UserStore = context.UserStore
location = "/client#/jamclass/book-lesson/test-drive_" + teacher_id
else
# the user bought test drive, but 'cold' , i.e., no teacher in context
- if testDriveCount == 1
+ if testDriveCount == '1'
text = "You now have 1 TestDrive credit.
We've taken you to the Teacher Search screen, so you can search for teachers right for you."
location = "/client#/teachers/search"
else