This commit is contained in:
Ana María Martínez Gómez 2017-01-26 15:36:04 +00:00 committed by GitHub
commit 24582706be
9 changed files with 311 additions and 125 deletions

View file

@ -17,5 +17,32 @@ describe EventSchedule do
it { is_expected.to validate_presence_of(:event) }
it { is_expected.to validate_presence_of(:room) }
it { is_expected.to validate_presence_of(:start_time) }
describe '#not_overlapping' do
let!(:event) { create(:event, event_type: create(:event_type, length: 60)) }
let!(:event2) { create(:event, event_type: create(:event_type, length: 30), program: event.program) }
let!(:schedule) { create(:schedule, program: event.program) }
let!(:room) { create(:room, venue: create(:venue, conference: event.program.conference)) }
let!(:event_schedule) { create(:event_schedule, schedule: schedule, event: event, room: room, start_time: event.program.conference.start_date.tomorrow.to_time + 60.minutes) }
describe "can't be scheduled at the same time than other event in the same room" do
it 'case 1' do
expect(build(:event_schedule, schedule: schedule, event: event2, room: room, start_time: event_schedule.start_time - 15.minutes)).to_not be_valid
end
it 'case 2' do
expect(build(:event_schedule, schedule: schedule, event: event2, room: room, start_time: event_schedule.start_time + 45.minutes)).to_not be_valid
end
it 'case 3' do
expect(build(:event_schedule, schedule: schedule, event: event2, room: room, start_time: event_schedule.start_time + 15.minutes)).to_not be_valid
end
it 'case 4' do
event2.event_type = create(:event_type, length: 120)
expect(build(:event_schedule, schedule: schedule, event: event2, room: room, start_time: event_schedule.start_time - 30.minutes)).to_not be_valid
end
end
end
end
end