mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Tests for room model
This commit is contained in:
parent
3dc7aaf4ea
commit
69a4139268
1 changed files with 26 additions and 0 deletions
26
spec/models/room_spec.rb
Normal file
26
spec/models/room_spec.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Room do
|
||||
subject { create(:room) }
|
||||
|
||||
describe 'validation' do
|
||||
it { should validate_presence_of(:name) }
|
||||
it { should validate_presence_of(:venue_id) }
|
||||
it { should validate_numericality_of(:size).only_integer.is_greater_than(0).allow_nil }
|
||||
end
|
||||
|
||||
describe 'association' do
|
||||
it { should belong_to(:venue) }
|
||||
it { should have_many(:events).dependent(:nullify) }
|
||||
end
|
||||
|
||||
describe 'callback' do
|
||||
after { subject.run_callbacks(:create) }
|
||||
|
||||
it '#generate_guid' do
|
||||
regex_base64 = %r{^(?:[A-Za-z_\-0-9+\/]{4}\n?)*(?:[A-Za-z_\-0-9+\/]{2}|[A-Za-z_\-0-9+\/]{3}=)?$}
|
||||
expect(subject).to receive(:generate_guid)
|
||||
expect(subject.guid).to match regex_base64
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue