35 lines
1.2 KiB
Ruby
35 lines
1.2 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe SchoolInvitation do
|
|
|
|
let(:school) {FactoryGirl.create(:school)}
|
|
|
|
it "created by factory" do
|
|
FactoryGirl.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
|
|
|
|
FactoryGirl.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
|
|
|
|
FactoryGirl.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
|
|
|
|
FactoryGirl.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 |