diff --git a/app/models/conference.rb b/app/models/conference.rb index 6c1c44e..d45f920 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 } diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 1cb520a..1a9df0a 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -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