2016-07-08 13:27:42 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe EventSchedule do
|
2016-08-23 10:23:26 -04:00
|
|
|
subject { create(:event_schedule) }
|
|
|
|
|
let(:schedule) { create(:schedule) }
|
|
|
|
|
let(:program) { create(:program, selected_schedule: schedule) }
|
|
|
|
|
let!(:current_event_schedule) { create(:current_event_schedule, schedule: program.selected_schedule) }
|
|
|
|
|
let!(:past_event_schedule) { create(:past_event_schedule) }
|
|
|
|
|
let!(:future_event_schedule) { create(:future_event_schedule) }
|
2016-07-08 13:27:42 +02:00
|
|
|
|
|
|
|
|
describe 'association' do
|
|
|
|
|
it { should belong_to(:schedule) }
|
|
|
|
|
it { should belong_to(:event) }
|
|
|
|
|
it { should belong_to(:room) }
|
|
|
|
|
end
|
2016-07-26 16:20:31 +02:00
|
|
|
|
|
|
|
|
describe 'validation' do
|
2016-08-04 13:16:32 +02:00
|
|
|
it 'has a valid factory' do
|
|
|
|
|
expect(build(:event_schedule)).to be_valid
|
|
|
|
|
end
|
|
|
|
|
|
2016-07-26 16:20:31 +02:00
|
|
|
it { is_expected.to validate_presence_of(:schedule) }
|
|
|
|
|
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) }
|
|
|
|
|
end
|
2016-08-23 10:23:26 -04:00
|
|
|
|
|
|
|
|
describe 'scope' do
|
|
|
|
|
context 'current' do
|
|
|
|
|
it 'returns only current events' do
|
|
|
|
|
expect(program.selected_schedule.event_schedules.current).to match_array([current_event_schedule])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-07-08 13:27:42 +02:00
|
|
|
end
|