2019-04-28 21:10:54 +03:00
|
|
|
require "rails_helper"
|
2014-11-05 11:45:04 +02:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
RSpec.describe Hall, type: :model do
|
|
|
|
it "is invalid without a name" do
|
|
|
|
expect(build(:hall, name: "")).to have_error_on :name
|
2014-11-05 11:45:04 +02:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "belongs to a conference" do
|
2014-11-05 11:45:04 +02:00
|
|
|
conference = create :conference
|
|
|
|
expect(build(:hall, conference_id: conference.id).conference).to eq conference
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "has many slots" do
|
2014-11-05 11:45:04 +02:00
|
|
|
hall = create :hall
|
|
|
|
slot = create :slot, hall: hall
|
|
|
|
expect(hall.slots).to include slot
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
it "destroys all associated slots when destroyed" do
|
2014-11-05 11:45:04 +02:00
|
|
|
hall = create :hall
|
|
|
|
create :slot, hall: hall
|
|
|
|
expect { hall.destroy }.to change { Slot.count }.by(-1)
|
|
|
|
end
|
|
|
|
end
|