45 lines
1.6 KiB
Ruby
45 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe LessonSession do
|
|
|
|
let(:user) {FactoryGirl.create(:user, stored_credit_card: false, remaining_free_lessons: 1, remaining_test_drives: 1)}
|
|
let(:teacher) {FactoryGirl.create(:teacher_user)}
|
|
|
|
let(:lesson_session) {FactoryGirl.create(:lesson_session, student: user, teacher: teacher)}
|
|
let(:lesson_session2) {FactoryGirl.create(:lesson_session, student: user, teacher: teacher)}
|
|
describe "accept" do
|
|
it "can accept" do
|
|
|
|
end
|
|
end
|
|
describe "index" do
|
|
it "finds single lesson as student" do
|
|
|
|
# just sanity check that the lesson_session Factory is doing what it should
|
|
lesson_session.music_session.creator.should eql lesson_session.lesson_booking.user
|
|
lesson_session.lesson_booking.teacher.should eql teacher
|
|
|
|
query = LessonSession.index(user)[:query]
|
|
query.length.should eq 1
|
|
|
|
# make sure some random nobody can see this lesson session
|
|
query = LessonSession.index(FactoryGirl.create(:user))[:query]
|
|
query.length.should eq 0
|
|
end
|
|
|
|
it "finds single lesson as teacher" do
|
|
|
|
# just sanity check that the lesson_session Factory is doing what it should
|
|
lesson_session.music_session.creator.should eql lesson_session.lesson_booking.user
|
|
lesson_session.lesson_booking.teacher.should eql teacher
|
|
|
|
query = LessonSession.index(teacher, {as_teacher: true})[:query]
|
|
query.length.should eq 1
|
|
|
|
# make sure some random nobody can see this lesson session
|
|
query = LessonSession.index(FactoryGirl.create(:user), {as_teacher: true})[:query]
|
|
query.length.should eq 0
|
|
end
|
|
end
|
|
end
|