clarion/spec/models/hall_spec.rb

25 lines
631 B
Ruby
Raw Permalink Normal View History

2019-04-28 21:10:54 +03:00
require "rails_helper"
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
end
2019-04-28 21:10:54 +03:00
it "belongs to a conference" do
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
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
hall = create :hall
create :slot, hall: hall
expect { hall.destroy }.to change { Slot.count }.by(-1)
end
end