Add missing specs for Tracks, Halls and Slots
Document the behaviour of Tracks, Slots and Halls with specs. Leave the association between slots and events pending for now.
This commit is contained in:
parent
fd9e53e1c0
commit
fac65a167a
9
spec/factories/slots.rb
Normal file
9
spec/factories/slots.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :slot do
|
||||||
|
starts_at { Time.now }
|
||||||
|
ends_at { Time.now + 45.minutes }
|
||||||
|
hall
|
||||||
|
end
|
||||||
|
end
|
24
spec/models/hall_spec.rb
Normal file
24
spec/models/hall_spec.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Hall, :type => :model do
|
||||||
|
it 'is invalid without a name' do
|
||||||
|
expect(build(:hall, name: '')).to have_error_on :name
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'belongs to a conference' do
|
||||||
|
conference = create :conference
|
||||||
|
expect(build(:hall, conference_id: conference.id).conference).to eq conference
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has many slots' do
|
||||||
|
hall = create :hall
|
||||||
|
slot = create :slot, hall: hall
|
||||||
|
expect(hall.slots).to include slot
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'destroys all associated slots when destroyed' do
|
||||||
|
hall = create :hall
|
||||||
|
create :slot, hall: hall
|
||||||
|
expect { hall.destroy }.to change { Slot.count }.by(-1)
|
||||||
|
end
|
||||||
|
end
|
14
spec/models/slot_spec.rb
Normal file
14
spec/models/slot_spec.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Slot, :type => :model do
|
||||||
|
it 'belongs to a hall' do
|
||||||
|
hall = create :hall
|
||||||
|
expect(build(:slot, hall_id: hall.id).hall).to eq hall
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'belongs to an event' do
|
||||||
|
pending 'Events not implemented'
|
||||||
|
event = create :event
|
||||||
|
expect(build(:slot, event_id: event.id).event).to eq event
|
||||||
|
end
|
||||||
|
end
|
@ -16,4 +16,9 @@ RSpec.describe Track, :type => :model do
|
|||||||
expect(build(:track, color: '#000000')).to_not have_error_on :color
|
expect(build(:track, color: '#000000')).to_not have_error_on :color
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'belongs to a conference' do
|
||||||
|
conference = create :conference
|
||||||
|
expect(build(:track, conference_id: conference.id).conference).to eq conference
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user