Automatically create an associated CFP with a Conference

Make sure there is always an associated unopened call for participation
for each conference.
This commit is contained in:
Petko Bordjukov 2015-05-23 18:47:08 +03:00
parent 463e43226e
commit 5e9914875c
2 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,8 @@ class Conference < ActiveRecord::Base
accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true
after_create :create_call_for_participation
def submissions_grouped_by_day
submissions = events.group('date(events.created_at)').select('events.created_at, count(events.id) as number')
submissions.group_by { |s| s.created_at.to_date }

View File

@ -99,6 +99,11 @@ RSpec.describe Conference, :type => :model do
conference.destroy
expect { CallForParticipation.find(call_for_participation.id) }.to raise_exception ActiveRecord::RecordNotFound
end
it 'creates an associated call for participation when the conference is created' do
conference.save
expect(conference.call_for_participation).to be_present
end
end
it 'accepts nested attributes for tracks' do