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:
AEtherC0r3 2017-05-30 20:54:48 +03:00 committed by Stella Rouzi
parent 7fd738bc7d
commit c3eb178546
8 changed files with 120 additions and 5 deletions

View file

@ -240,4 +240,23 @@ describe Program do
end
end
describe '#cfp' do
it 'returns the cfp for events' do
create(:cfp, cfp_type: 'events', program: program, end_date: Date.current + 1)
expect(program.cfp).to be_a Cfp
expect(program.cfp.cfp_type).to eq('events')
end
it 'returns nil if the program doesn\'t have a cfp' do
expect(program.cfp).to eq(nil)
end
end
describe '#remaining_cfp_types' do
it 'returns an array with the types for which a cfp doesn\'t exist' do
expect(program.remaining_cfp_types).to eq(Cfp::TYPES)
create(:cfp, cfp_type: 'events', program: program, end_date: Date.current + 1)
expect(program.remaining_cfp_types).to eq([])
end
end
end