2014-05-08 14:52:33 -07:00
|
|
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
|
|
|
|
|
|
|
|
|
FactoryGirl.define do
|
|
|
|
|
factory :event do
|
2016-04-30 17:56:23 +02:00
|
|
|
title { Faker::Hipster.sentence }
|
|
|
|
|
abstract { Faker::Hipster.paragraph(2) }
|
|
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
program
|
2014-05-08 14:52:33 -07:00
|
|
|
|
|
|
|
|
after(:build) do |event|
|
2016-03-12 21:08:43 +05:30
|
|
|
event.event_users << build(:submitter) unless event.submitter # so that we don't have two submitters
|
2015-04-14 17:33:59 +02:00
|
|
|
# set an event_type if none is passed to the factory.
|
|
|
|
|
# needs to be created here because otherwise it doesn't belong to the
|
|
|
|
|
# same conference as the event
|
2015-10-25 13:29:02 +02:00
|
|
|
event.event_type ||= build(:event_type, program: event.program)
|
2014-05-08 14:52:33 -07:00
|
|
|
end
|
2015-04-14 17:33:59 +02:00
|
|
|
|
|
|
|
|
factory :event_full do
|
|
|
|
|
difficulty_level
|
|
|
|
|
track
|
|
|
|
|
after(:build) do |event|
|
|
|
|
|
event.commercials << build(:event_commercial, commercialable: event)
|
2015-10-25 13:29:02 +02:00
|
|
|
event.difficulty_level = build(:difficulty_level, program: event.program)
|
|
|
|
|
event.track = build(:track, program: event.program)
|
2016-07-08 13:27:42 +02:00
|
|
|
unless event.program.conference.venue
|
|
|
|
|
create(:venue, conference: event.program.conference)
|
2015-11-07 11:43:36 +02:00
|
|
|
end
|
2015-08-25 14:41:09 +02:00
|
|
|
event.comment_threads << build(:comment, commentable: event)
|
2015-04-14 17:33:59 +02:00
|
|
|
end
|
2016-06-15 20:54:51 +03:00
|
|
|
|
|
|
|
|
factory :event_scheduled do
|
|
|
|
|
after(:build) do |event|
|
|
|
|
|
event.state = 'confirmed'
|
2016-07-08 13:27:42 +02:00
|
|
|
event.event_schedules << build(:event_schedule, event: event)
|
2016-06-15 20:54:51 +03:00
|
|
|
end
|
|
|
|
|
end
|
2015-04-14 17:33:59 +02:00
|
|
|
end
|
2014-05-08 14:52:33 -07:00
|
|
|
end
|
|
|
|
|
end
|