157 lines
4.5 KiB
Ruby
157 lines
4.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Teacher do
|
|
|
|
let(:user) { FactoryGirl.create(:user) }
|
|
let(:user2) { FactoryGirl.create(:user) }
|
|
let(:fan) { FactoryGirl.create(:fan) }
|
|
let(:genre1) { FactoryGirl.create(:genre) }
|
|
let(:genre2) { FactoryGirl.create(:genre) }
|
|
let(:subject1) { FactoryGirl.create(:subject) }
|
|
let(:subject2) { FactoryGirl.create(:subject) }
|
|
let(:language1) { FactoryGirl.create(:language) }
|
|
let(:language2) { FactoryGirl.create(:language) }
|
|
let(:instrument1) { FactoryGirl.create(:instrument, :description => 'a great instrument')}
|
|
let(:instrument2) { FactoryGirl.create(:instrument, :description => 'an ok instrument')}
|
|
|
|
BIO = "Once a man learned a guitar."
|
|
describe "can create" do
|
|
it "a simple teacher" do
|
|
teacher = Teacher.new
|
|
teacher.user = user;
|
|
teacher.biography = BIO
|
|
teacher.introductory_video = "youtube.com?xyz"
|
|
teacher.save.should be_true
|
|
t = Teacher.find(teacher.id)
|
|
t.biography.should == BIO
|
|
t.introductory_video.should == "youtube.com?xyz"
|
|
end
|
|
|
|
|
|
it "a simple teacher" do
|
|
teacher = user.build_teacher
|
|
teacher.instruments << instrument1
|
|
teacher.instruments << instrument2
|
|
teacher.save.should be_true
|
|
puts teacher.errors.messages.inspect
|
|
t = Teacher.find(teacher.id)
|
|
t.instruments.should have(2).items
|
|
end
|
|
|
|
end
|
|
|
|
describe "using save_teacher can create" do
|
|
it "introduction" do
|
|
teacher = Teacher.save_teacher(
|
|
user,
|
|
biography: BIO,
|
|
introductory_video: "youtube.com?xyz",
|
|
years_teaching: 21,
|
|
years_playing: 12
|
|
)
|
|
|
|
teacher.should_not be_nil
|
|
teacher.id.should_not be_nil
|
|
t = Teacher.find(teacher.id)
|
|
t.biography.should == BIO
|
|
t.introductory_video.should == "youtube.com?xyz"
|
|
t.years_teaching.should == 21
|
|
t.years_playing.should == 12
|
|
end
|
|
|
|
it "basics" do
|
|
teacher = Teacher.save_teacher(
|
|
user,
|
|
instruments: [instrument1, instrument2],
|
|
subjects: [subject1, subject2],
|
|
genres: [genre1, genre2],
|
|
languages: [language1, language2],
|
|
teaches_age_lower: 10,
|
|
teaches_age_upper: 20,
|
|
teaches_beginner: true,
|
|
teaches_intermediate: false,
|
|
teaches_advanced: true
|
|
)
|
|
|
|
t = Teacher.find(teacher.id)
|
|
|
|
# Instruments
|
|
t.instruments.should have(2).items
|
|
|
|
# Genres
|
|
t.genres.should have(2).items
|
|
|
|
# Subjects
|
|
t.subjects.should have(2).items
|
|
|
|
# Languages
|
|
t.languages.should have(2).items
|
|
|
|
t.teaches_age_lower.should == 10
|
|
t.teaches_age_upper.should == 20
|
|
t.teaches_beginner.should be_true
|
|
t.teaches_intermediate.should be_false
|
|
t.teaches_advanced.should be_true
|
|
|
|
end
|
|
|
|
it "experience" do
|
|
experience = [{
|
|
experience_type: "teaching",
|
|
name: "Professor",
|
|
organization: "SHSU",
|
|
start_year: 1994,
|
|
end_year: 2004
|
|
}
|
|
]
|
|
|
|
teacher = Teacher.save_teacher(user, experience: experience)
|
|
teacher.should_not be_nil
|
|
t = Teacher.find(teacher.id)
|
|
t.should_not be_nil
|
|
|
|
t.teacher_experiences.should have(1).items
|
|
end
|
|
|
|
it "lesson pricing" do
|
|
teacher = Teacher.save_teacher(
|
|
user,
|
|
prices_per_lesson: true,
|
|
prices_per_month: true,
|
|
lesson_duration_30: true,
|
|
lesson_duration_45: true,
|
|
lesson_duration_60: true,
|
|
lesson_duration_90: true,
|
|
lesson_duration_120: true,
|
|
price_per_lesson_cents: 3000,
|
|
price_per_month_cents: 3000,
|
|
price_duration_30_cents: 3000,
|
|
price_duration_45_cents: 3000,
|
|
price_duration_60_cents: 3000,
|
|
price_duration_90_cents: 3000,
|
|
price_duration_120_cents: 3000
|
|
)
|
|
|
|
teacher.should_not be_nil
|
|
teacher.id.should_not be_nil
|
|
t = Teacher.find(teacher.id)
|
|
t.prices_per_lesson.should be_true
|
|
t.prices_per_month.should be_true
|
|
t.lesson_duration_30.should be_true
|
|
t.lesson_duration_45.should be_true
|
|
t.lesson_duration_60.should be_true
|
|
t.lesson_duration_90.should be_true
|
|
t.lesson_duration_120.should be_true
|
|
t.price_per_lesson_cents.should == 3000
|
|
t.price_per_month_cents.should == 3000
|
|
t.price_duration_30_cents.should == 3000
|
|
t.price_duration_45_cents.should == 3000
|
|
t.price_duration_60_cents.should == 3000
|
|
t.price_duration_90_cents.should == 3000
|
|
t.price_duration_120_cents.should == 3000
|
|
end
|
|
|
|
|
|
end
|
|
end
|