forked from bofh/fetsite
nes neuigkeiten model specs
This commit is contained in:
@@ -3,9 +3,17 @@ require 'spec_helper'
|
|||||||
describe Neuigkeit do
|
describe Neuigkeit do
|
||||||
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
||||||
let(:user) {FactoryGirl.create(:user)}
|
let(:user) {FactoryGirl.create(:user)}
|
||||||
|
let(:calendar) {FactoryGirl.create(:calendar,updated_at: 1.hour.ago)}
|
||||||
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id))}
|
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id))}
|
||||||
let(:attachment) {FactoryGirl.build_stubbed(:attachment)}
|
let(:attachment) {FactoryGirl.build_stubbed(:attachment)}
|
||||||
|
|
||||||
|
let(:calentry) do
|
||||||
|
c = FactoryGirl.build(:calentry, calendar_id: calendar.id, start: 1.hour.ago, ende: 5.minutes.ago)
|
||||||
|
c.object=neuigkeit
|
||||||
|
c.save
|
||||||
|
c
|
||||||
|
end
|
||||||
|
|
||||||
[ :rubrik, :author].each do |attr| # :title,:text to be discussed
|
[ :rubrik, :author].each do |attr| # :title,:text to be discussed
|
||||||
it "should not be valid without #{attr}" do
|
it "should not be valid without #{attr}" do
|
||||||
neuigkeit.send("#{attr}=".to_sym,nil)
|
neuigkeit.send("#{attr}=".to_sym,nil)
|
||||||
@@ -31,8 +39,16 @@ describe Neuigkeit do
|
|||||||
expect { neuigkeit.attachments << attachment }.to change {neuigkeit.picture_robust}
|
expect { neuigkeit.attachments << attachment }.to change {neuigkeit.picture_robust}
|
||||||
end
|
end
|
||||||
it "is an event if it has a calentry" do
|
it "is an event if it has a calentry" do
|
||||||
expect(neuigkeit.event?).to be false
|
expect(neuigkeit).not_to be_is_event
|
||||||
expect{neuigkeit.calentries << calentry}.to change(neuigkeit, :event?)
|
neuigkeit.calentries << calentry
|
||||||
|
expect(neuigkeit).to be_is_event
|
||||||
|
|
||||||
|
end
|
||||||
|
it "it is published if datum is in the past" do
|
||||||
|
neuigkeit.datum=5.hours.ago
|
||||||
|
expect(neuigkeit).to be_published
|
||||||
|
end
|
||||||
|
it "" do
|
||||||
end
|
end
|
||||||
|
|
||||||
pending "has questions"
|
pending "has questions"
|
||||||
|
|||||||
Reference in New Issue
Block a user