Allow max_attendees to be nil
This commit is contained in:
parent
65ee166570
commit
528243c8b9
7 changed files with 50 additions and 41 deletions
|
|
@ -24,30 +24,6 @@ describe Event do
|
|||
it { is_expected.to validate_presence_of(:program) }
|
||||
it { is_expected.to validate_presence_of(:event_type) }
|
||||
|
||||
describe '#max_attendees_and_require_registration' do
|
||||
it 'allows user to set max_attendees, only if require_registration is set' do
|
||||
event.require_registration = true
|
||||
event.max_attendees = 2
|
||||
|
||||
expect(event.valid?).to eq true
|
||||
end
|
||||
|
||||
it 'does not allow max_attendees to be set without require_registration' do
|
||||
event.max_attendees = 2
|
||||
|
||||
expect(event.valid?).to eq false
|
||||
expect(event.errors[:require_registration]).to eq ['must be enabled, when you set max_attendees']
|
||||
end
|
||||
|
||||
it 'does not allow require_registration to be set without max_attendees' do
|
||||
event.require_registration = true
|
||||
event.max_attendees = nil
|
||||
|
||||
expect(event.valid?).to eq false
|
||||
expect(event.errors[:max_attendees]).to eq ['must be enabled, when you set require_registration']
|
||||
end
|
||||
end
|
||||
|
||||
describe 'max_attendees_no_more_than_room_size' do
|
||||
before :each do
|
||||
event.room = create(:room, size: 3)
|
||||
|
|
@ -148,20 +124,39 @@ describe Event do
|
|||
describe '#registration_possible?' do
|
||||
describe 'when the event requires registration' do
|
||||
before :each do
|
||||
event.state = 'confirmed'
|
||||
event.require_registration = true
|
||||
event.max_attendees = 3
|
||||
event.registrations << create(:registration)
|
||||
event.save!
|
||||
end
|
||||
|
||||
it 'returns true, if the event has no max_attendees' do
|
||||
event.max_attendees = nil
|
||||
event.save!
|
||||
expect(event.registration_possible?).to eq true
|
||||
end
|
||||
|
||||
it 'returns true, if the limit has not been reached' do
|
||||
expect(event.registration_possible?).to eq true
|
||||
end
|
||||
|
||||
it 'returns true, if the event is confirmed' do
|
||||
event.save!
|
||||
expect(event.registration_possible?).to eq true
|
||||
end
|
||||
|
||||
it 'returns false, if the limit has been reached' do
|
||||
event.registrations << create(:registration)
|
||||
event.registrations << create(:registration)
|
||||
expect(event.registration_possible?).to eq false
|
||||
end
|
||||
|
||||
it 'returns false, if the event is not confirmed' do
|
||||
event.state = 'new'
|
||||
event.save!
|
||||
expect(event.registration_possible?).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the event does not require registration' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue