AutoCommit Don Sep 10 21:03:02 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-09-10 21:03:02 +02:00
parent f59f0cb05a
commit edaf154549
4 changed files with 32 additions and 16 deletions

View File

@@ -1,20 +1,25 @@
require 'spec_helper'
describe Calentry do
it "should be valid with full data" do
e = FactoryGirl.build(:calentry)
c = FactoryGirl.create(:calendar)
e.calendars << c
e.should be_valid
end
[:ende,:start,:typ].each do |attr|
it "should not be valid without #{attr}" do
e= FactoryGirl.build(:calentry, attr => nil)
c=FactoryGirl.create(:calendar)
e.calendars << c
e.should_not be_valid
e.should have_at_least(1).errors_on(attr)
end
before(:each) do
@user = FactoryGirl.create(:user)
end
let(:rubrik) {FactoryGirl.create(:rubrik)}
let(:user) {FactoryGirl.create(:user)}
let(:calendar) {FactoryGirl.create(:calendar)}
let(:neuigkeit) {FactoryGirl.create(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id)}
it "should be valid with full data" do
e = FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id)
expect(e).to be_valid
end
[:ende,:start,:typ].each do |attr|
it "is not valid without #{attr}" do
e= FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id, attr => nil)
expect(e).not_to be_valid
expect(e).to have_at_least(1).errors_on(attr)
end
end
end