jam-cloud/ruby/spec/jam_ruby/models/school_spec.rb

30 lines
778 B
Ruby
Raw Permalink Normal View History

require 'spec_helper'
describe School do
it "created by factory" do
FactoryGirl.create(:school)
end
it "has correct associations" do
school = FactoryGirl.create(:school)
school.should eql school.user.owned_school
student = FactoryGirl.create(:user, school: school)
teacher = FactoryGirl.create(:teacher, school: school)
school.reload
school.students.to_a.should eql [student]
school.teachers.to_a.should eql [teacher]
student.school.should eql school
teacher.school.should eql school
end
it "updates" do
school = FactoryGirl.create(:school)
school.update_from_params({name: 'hahah', scheduling_communication: 'school', correspondence_email: 'bobby@jamkazam.com'})
school.errors.any?.should be_false
end
end