forked from bofh/fetsite
62 lines
1.9 KiB
Ruby
62 lines
1.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Neuigkeit do
|
|
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
|
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(: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
|
|
it "should not be valid without #{attr}" do
|
|
neuigkeit.send("#{attr}=".to_sym,nil)
|
|
expect(neuigkeit).not_to be_valid
|
|
expect(neuigkeit.errors[attr]).to have_at_least(1).items
|
|
end
|
|
end
|
|
it "should be created" do
|
|
expect(neuigkeit).to be_valid
|
|
expect(neuigkeit.save).to be true
|
|
end
|
|
|
|
it "should be valid" do
|
|
fp = FactoryGirl.build(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id)
|
|
expect(fp).to be_valid
|
|
end
|
|
it "responds to attachments" do
|
|
expect(neuigkeit.respond_to?(:attachments)).to be true
|
|
end
|
|
pending "uses titlepic attachments as picture" do # this test seems broken
|
|
expect(neuigkeit.respond_to?(:picture_robust)).to be true
|
|
attachment.flag_titlepic = true
|
|
expect { neuigkeit.attachments << attachment }.to change {neuigkeit.picture_robust}
|
|
end
|
|
it "is an event if it has a calentry" do
|
|
expect(neuigkeit).not_to be_is_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
|
|
|
|
pending "has questions"
|
|
pending "has nlinks"
|
|
pending "has calentries"
|
|
pending "can be an event"
|
|
pending "is published by date"
|
|
pending "has meeting"
|
|
pending "is shareable"
|
|
end
|