AutoCommit Don Sep 10 22:03:01 CEST 2015
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Calentry do
|
describe Calentry do
|
||||||
before(:each) do
|
|
||||||
@user = FactoryGirl.create(:user)
|
|
||||||
end
|
|
||||||
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)}
|
let(:calendar) {FactoryGirl.create(:calendar,updated_at: 1.hour.ago)}
|
||||||
let(:neuigkeit) {FactoryGirl.create(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id)}
|
let(:neuigkeit) {FactoryGirl.create(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id, updated_at: 1.hour.ago)}
|
||||||
|
subject(:calentry) {FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id)}
|
||||||
|
|
||||||
it "should be valid with full data" do
|
it "is valid with full data" do
|
||||||
e = FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id)
|
expect(calentry).to be_valid
|
||||||
expect(e).to be_valid
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[:ende,:start,:typ].each do |attr|
|
[:ende,:start,:typ].each do |attr|
|
||||||
@@ -21,5 +19,39 @@ describe Calentry do
|
|||||||
expect(e).to have_at_least(1).errors_on(attr)
|
expect(e).to have_at_least(1).errors_on(attr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
it "updates updated_at of neuigekit" do
|
||||||
|
expect {calentry.dauer+=1.hour;calentry.save}.to change{calentry.object.updated_at}
|
||||||
|
end
|
||||||
|
it "updates updated_at of calendar" do
|
||||||
|
expect {calentry.dauer+=1.hour;calentry.save}.to change{calentry.calendar.updated_at}
|
||||||
|
end
|
||||||
|
it "changes ende with dauer" do
|
||||||
|
expect {calentry.dauer=7}.to change(calentry,:ende).to(calentry.start+7.hours)
|
||||||
|
end
|
||||||
|
it "changes dauer with ende" do
|
||||||
|
expect {calentry.ende=calentry.start+7.hours}.to change(calentry,:dauer).to(7)
|
||||||
|
end
|
||||||
|
it "sets is upcomming" do
|
||||||
|
calentry.start=1.hour.from_now
|
||||||
|
calentry.dauer=2
|
||||||
|
expect(calentry.is_upcomming?).to be true
|
||||||
|
expect(calentry.is_past?).to be false
|
||||||
|
expect(calentry.is_ongoing?).to be false
|
||||||
|
|
||||||
|
calentry.start=1.hour.ago
|
||||||
|
calentry.dauer=2
|
||||||
|
|
||||||
|
expect(calentry.is_upcomming?).to be false
|
||||||
|
expect(calentry.is_past?).to be false
|
||||||
|
expect(calentry.is_ongoing?).to be true
|
||||||
|
|
||||||
|
calentry.start=4.hour.ago
|
||||||
|
calentry.dauer=2
|
||||||
|
|
||||||
|
expect(calentry.is_upcomming?).to be false
|
||||||
|
expect(calentry.is_past?).to be true
|
||||||
|
expect(calentry.is_ongoing?).to be false
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user