forked from bofh/fetsite
77 lines
2.3 KiB
Ruby
77 lines
2.3 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Neuigkeit do
|
|
|
|
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, :with_rubrik))}
|
|
let(:intern_neuigkeit) {FactoryGirl.build(:neuigkeit, :with_intern_rubrik)}
|
|
let(:unpublished_neuigkeit){FactoryGirl.build(:neuigkeit, :unpublished,:with_rubrik)}
|
|
let(:attachment) {FactoryGirl.build_stubbed(:attachment)}
|
|
|
|
let(:calentry) {
|
|
FactoryGirl.build(:calentry, start: 1.hour.ago, ende: 5.minutes.ago)
|
|
}
|
|
|
|
let(:object_variable) {neuigkeit}
|
|
|
|
it_behaves_like "a valid object"
|
|
|
|
it "is published" do expect(neuigkeit).to be_published end
|
|
it "is public" do expect(neuigkeit).to be_public end
|
|
it "has no meeting" do expect(neuigkeit).not_to be_is_annoncement end
|
|
|
|
# it "failes" do expect(true).to be_falsey end
|
|
|
|
it "is published if datum is in the past" do
|
|
neuigkeit.datum=5.hours.ago
|
|
expect(neuigkeit).to be_published
|
|
end
|
|
it "is unpublished if datum is in the future" do
|
|
neuigkeit.datum=5.hours.from_now
|
|
expect(neuigkeit).not_to be_published
|
|
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
|
|
|
|
context "with meeting" do
|
|
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, :with_rubrik, :with_meeting))}
|
|
let(:object_variable) {neuigkeit}
|
|
it_behaves_like "a valid object"
|
|
it "has meeting" do expect(neuigkeit.meeting).to be_truthy end
|
|
it "is annoncement" do expect(neuigkeit).to be_is_annoncement end
|
|
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 "" 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
|