Limit event types lenght

This commit is contained in:
Ana 2016-05-31 16:51:12 +02:00
parent 301ad1c722
commit 55c41810b2
4 changed files with 50 additions and 6 deletions

View file

@ -366,8 +366,8 @@ describe Conference do
describe 'program hours and minutes' do
before(:each) do
@long = create(:event_type, length: 100)
@short = create(:event_type, length: 10)
@long = create(:event_type, length: 120)
@short = create(:event_type, length: 15)
end
describe '#actual_program_minutes' do
@ -376,8 +376,8 @@ describe Conference do
create(:event, program: subject.program, event_type: @long)
create(:event, program: subject.program, event_type: @short)
create(:event, program: subject.program, event_type: @short)
result_in_hours = 4
result_in_minutes = 220
result_in_hours = 5
result_in_minutes = 270
expect(subject.current_program_hours).to eq(result_in_hours)
expect(subject.current_program_minutes).to eq(result_in_minutes)
end
@ -397,7 +397,7 @@ describe Conference do
create(:event, program: subject.program, event_type: @short, created_at: Time.now - 3.days)
create(:event, program: subject.program, event_type: @short)
result_in_hours = 2
result_in_minutes = 110
result_in_minutes = 135
expect(subject.new_program_hours(Time.now - 5.minutes)).to eq(result_in_hours)
expect(subject.new_program_minutes(Time.now - 5.minutes)).to eq(result_in_minutes)
end

View file

@ -0,0 +1,32 @@
require 'spec_helper'
describe EventType do
let(:conference) { create(:conference) }
let(:event_type) { create(:event_type, program: conference.program) }
describe 'association' do
it { is_expected.to belong_to :program }
it { is_expected.to have_many :events }
end
describe 'validation' do
it 'has a valid factory' do
expect(build(:event_type)).to be_valid
end
it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_presence_of(:minimum_abstract_length) }
it { is_expected.to validate_presence_of(:maximum_abstract_length) }
describe 'has a valid length' do
it 'length is greater than 0' do
should validate_numericality_of(:length).
is_greater_than(0)
end
it 'length is multiple of LENGTH_STEP' do
expect(build(:event_type, program: conference.program, length: 37)).not_to be_valid
end
end
end
end