43 lines
1.1 KiB
Ruby
43 lines
1.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Gremium do
|
|
it "can be created" do
|
|
g=FactoryGirl.build(:gremium)
|
|
expect(g.save).to be true
|
|
end
|
|
it "is valid with all attributes" do
|
|
g = FactoryGirl.build(:gremium)
|
|
g.should be_valid
|
|
end
|
|
[:name,:typ].each do |attr|
|
|
it "should not be valid without #{attr}" do
|
|
g = FactoryGirl.build(:gremium)
|
|
g.send("#{attr}=".to_sym,nil)
|
|
expect(g).not_to be_valid
|
|
expect(g.errors[attr]).to have_at_least(1).items
|
|
|
|
end
|
|
end
|
|
it "is in tabs if typ is 1 or 3" do
|
|
g = FactoryGirl.create(:gremium, typ: 1)
|
|
expect(Gremium.tabs).to eq([g])
|
|
end
|
|
it "is not in tabs if typ is not 1 or 3" do
|
|
g = FactoryGirl.create(:gremium, typ: 2)
|
|
expect(Gremium.tabs).to eq([])
|
|
end
|
|
it "destroys memberships if its destroyed" do
|
|
g=FactoryGirl.create(:gremium)
|
|
fp=FactoryGirl.create(:fetprofile)
|
|
m=FactoryGirl.create(:membership, gremium_id: g.id, fetprofile_id: fp.id)
|
|
expect{g.destroy}.to change {Membership.count}.by(-1)
|
|
|
|
|
|
end
|
|
|
|
it "responds to title" do
|
|
g=FactoryGirl.build(:gremium)
|
|
expect(g.respond_to?(:title)).to be true
|
|
end
|
|
end
|