Tests for the new associations and models

Tests for the schedule versioning new associations and models
This commit is contained in:
Ana 2016-07-08 13:27:42 +02:00
parent c047ffd699
commit e7a30302ff
9 changed files with 66 additions and 17 deletions

View file

@ -0,0 +1,10 @@
require 'spec_helper'
describe EventSchedule do
describe 'association' do
it { should belong_to(:schedule) }
it { should belong_to(:event) }
it { should belong_to(:room) }
end
end

View file

@ -27,7 +27,10 @@ describe Event do
describe 'max_attendees_no_more_than_room_size' do
before :each do
event.room = create(:room, size: 3)
unless (venue = event.program.conference.venue)
venue = create(:venue, conference: event.program.conference)
end
create(:event_schedule, event: event, room: create(:room, venue: venue, size: 3))
event.require_registration = true
end
@ -116,8 +119,7 @@ describe Event do
describe '#scheduled?' do
it { expect(event.scheduled?).to eq false }
it 'returns true if the event is scheduled' do
event.room = create(:room)
event.start_time = conference.start_date.to_time
create(:event_schedule, event: event)
expect(event.scheduled?).to eq true
end
end
@ -259,11 +261,11 @@ describe Event do
describe '#as_json' do
it 'adds the event\'s room_guid, track_color and length' do
event.room = create(:room)
create(:event_schedule, event: event)
event.track = create(:track, color: '#efefef')
json_hash = event.as_json(nil)
expect(json_hash[:room_guid]).to eq(event.room.guid)
expect(json_hash[:room_guid]).to eq(event.scheduled_room.guid)
expect(json_hash[:track_color]).to eq('#EFEFEF')
expect(json_hash[:length]).to eq(30)
end

View file

@ -8,6 +8,7 @@ describe Program do
describe 'association' do
it { is_expected.to belong_to :conference }
it { is_expected.to have_one(:cfp).dependent(:destroy) }
it { is_expected.to have_many(:schedules).dependent(:destroy) }
it { is_expected.to have_many(:event_types).dependent(:destroy) }
it { is_expected.to have_many(:tracks).dependent(:destroy) }
it { is_expected.to have_many(:difficulty_levels).dependent(:destroy) }

View file

@ -11,7 +11,7 @@ describe Room do
describe 'association' do
it { should belong_to(:venue) }
it { should have_many(:events).dependent(:nullify) }
it { should have_many(:event_schedules).dependent(:nullify) }
end
describe 'callback' do

View file

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