This commit is contained in:
Anitha Palanisamy 2017-01-31 13:57:04 +00:00 committed by GitHub
commit f1e37df5a0
21 changed files with 264 additions and 3 deletions

View file

@ -1,6 +1,12 @@
require 'spec_helper'
describe EventSchedule do
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) }
describe 'association' do
it { should belong_to(:schedule) }
@ -18,4 +24,12 @@ describe EventSchedule do
it { is_expected.to validate_presence_of(:room) }
it { is_expected.to validate_presence_of(:start_time) }
end
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
end

View file

@ -1,7 +1,6 @@
require 'spec_helper'
describe Schedule do
describe 'association' do
it { should belong_to(:program) }
it { should have_many(:event_schedules).dependent(:destroy) }