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

35 lines
1.2 KiB
Ruby

require 'spec_helper'
xdescribe SchoolInvitation do
let(:school) {FactoryBot.create(:school)}
it "created by factory" do
FactoryBot.create(:school_invitation)
end
it "created by method" do
SchoolInvitation.create(school.user, school, {as_teacher: true, first_name: "Bobby", last_name: "Jimes", email: "somewhere@jamkazam.com"})
end
describe "index" do
it "works" do
SchoolInvitation.index(school, {as_teacher: true})[:query].count.should eql 0
FactoryBot.create(:school_invitation)
SchoolInvitation.index(school, {as_teacher: true})[:query].count.should eql 0
SchoolInvitation.index(school, {as_teacher: false})[:query].count.should eql 0
FactoryBot.create(:school_invitation, school: school, as_teacher: true)
SchoolInvitation.index(school, {as_teacher: true})[:query].count.should eql 1
SchoolInvitation.index(school, {as_teacher: false})[:query].count.should eql 0
FactoryBot.create(:school_invitation, school: school, as_teacher: false)
SchoolInvitation.index(school, {as_teacher: true})[:query].count.should eql 1
SchoolInvitation.index(school, {as_teacher: false})[:query].count.should eql 1
end
end
end