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

@ -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