diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index 0cfdd37..42c878e 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -6,5 +6,11 @@ describe Attachment do it "responds to image" do expect(attachment.respond_to?(:image?)).to be true end - + it "is an image" do + expect(attachment.image?).to be true + end + it "is valid" do + expect(attachment).to be_valid + end + end diff --git a/spec/models/neuigkeit_spec.rb b/spec/models/neuigkeit_spec.rb index 5b7e972..817ea1b 100644 --- a/spec/models/neuigkeit_spec.rb +++ b/spec/models/neuigkeit_spec.rb @@ -4,6 +4,8 @@ describe Neuigkeit do let(:rubrik) {FactoryGirl.create(:rubrik)} let(:user) {FactoryGirl.create(:user)} let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id))} + let(:attachment) {FactoryGirl.build_stubbed(:attachment)} + [:title,:text, :rubrik, :author].each do |attr| it "should not be valid without #{attr}" do neuigkeit.send("#{attr}=".to_sym,nil) @@ -20,7 +22,19 @@ describe Neuigkeit do fp = FactoryGirl.build(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id) expect(fp).to be_valid end - pending "is parent for attachments " + it "responds to attachments" do + expect(neuigkeit.respond_to?(:attachments)).to be true + end + it "uses titlepic attachments as picture" do + 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.event?).to be false + expect{neuigkeit.calentries << calentry}.to change(neuigkeit, :event?) + end + pending "has questions" pending "has nlinks" pending "has calentries"