Introduce a CallForParticipation model
This commit is contained in:
parent
819e07338b
commit
8d5056e274
|
@ -0,0 +1,3 @@
|
|||
class CallForParticipation < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
end
|
|
@ -11,7 +11,7 @@ class Conference < ActiveRecord::Base
|
|||
has_many :tracks
|
||||
has_many :halls
|
||||
has_many :events, through: :tracks
|
||||
|
||||
has_one :call_for_participation, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class CreateCallForParticipations < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :call_for_participations do |t|
|
||||
t.references :conference, index: true, foreign_key: true
|
||||
t.datetime :opens_at
|
||||
t.datetime :closes_at
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :call_for_participation do
|
||||
conference nil
|
||||
opens_at "2015-04-20 18:40:43"
|
||||
closes_at "2015-04-20 18:40:43"
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CallForParticipation, type: :model do
|
||||
it 'belongs to a conference' do
|
||||
conference = create :conference
|
||||
cfp = create(:call_for_participation, conference_id: conference.id)
|
||||
expect(CallForParticipation.find(cfp.id).conference).to eq conference
|
||||
end
|
||||
end
|
|
@ -81,6 +81,26 @@ RSpec.describe Conference, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'call for participation association' do
|
||||
let(:conference) { build :conference }
|
||||
let(:call_for_participation) { build :call_for_participation }
|
||||
|
||||
before(:each) do
|
||||
conference.save
|
||||
call_for_participation.conference = conference
|
||||
call_for_participation.save
|
||||
end
|
||||
|
||||
it 'has one call for participation' do
|
||||
expect(conference.call_for_participation).to eq call_for_participation
|
||||
end
|
||||
|
||||
it 'destroys the associated call for participation when destroyed' do
|
||||
conference.destroy
|
||||
expect { CallForParticipation.find(call_for_participation.id) }.to raise_exception ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
it 'accepts nested attributes for tracks' do
|
||||
track_attributes = build(:track, conference: nil).attributes
|
||||
conference = create :conference
|
||||
|
|
Loading…
Reference in New Issue