mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Modify CFP to accept proposals for other things
Add field cfp_type and relevant validations Add Program#cfp to preserve backwards compatibility Add 'for_events' scope to the cfp, in order for it to be used like program.cfps.events Add useful methods Add rspec test for the new code The supported cfp types can be viewed via Cfp::TYPES
This commit is contained in:
parent
7fd738bc7d
commit
c3eb178546
8 changed files with 120 additions and 5 deletions
|
|
@ -1,8 +1,24 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Cfp do
|
||||
subject { create(:cfp) }
|
||||
let!(:conference) { create(:conference, end_date: Date.today) }
|
||||
let!(:cfp) { build(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: conference.program.id) }
|
||||
let!(:cfp) { create(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: conference.program.id) }
|
||||
|
||||
describe 'scope' do
|
||||
describe '#for_events' do
|
||||
it 'returns the cfp for events' do
|
||||
expect(conference.program.cfps.for_events).to be_a Cfp
|
||||
expect(conference.program.cfps.for_events.cfp_type).to eq('events')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
it { is_expected.to validate_presence_of(:cfp_type) }
|
||||
it { is_expected.to validate_inclusion_of(:cfp_type).in_array(Cfp::TYPES) }
|
||||
it { is_expected.to validate_uniqueness_of(:cfp_type).scoped_to(:program_id).case_insensitive }
|
||||
end
|
||||
|
||||
describe '#before_end_of_conference' do
|
||||
describe 'fails to save cfp' do
|
||||
|
|
@ -97,4 +113,28 @@ describe Cfp do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#open?' do
|
||||
context 'returns false' do
|
||||
it 'when start and end dates are in the past' do
|
||||
cfp.start_date = Date.current - 3
|
||||
cfp.end_date = Date.current - 1
|
||||
expect(cfp.open?).to eq(false)
|
||||
end
|
||||
|
||||
it 'when start and end dates are in the future' do
|
||||
cfp.start_date = Date.current + 1
|
||||
cfp.end_date = Date.current + 3
|
||||
expect(cfp.open?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'returns true' do
|
||||
it 'when start date is in the past and end date is in the future' do
|
||||
cfp.start_date = Date.current - 1
|
||||
cfp.end_date = Date.current + 1
|
||||
expect(cfp.open?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue