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|
|
2017-02-02 16:34:59 +02:00
|
|
|
event.submitter = build(:submitter).user unless event.submitter # so that we don't have two submitters
|
|
|
|
|
event.speakers << build(:speaker).user unless event.speakers.any?
|
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
|
|
|
|
|
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
|
2017-04-22 01:28:49 +05:30
|
|
|
transient do
|
|
|
|
|
hour nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
after(:build) do |event, evaluator|
|
2016-06-15 20:54:51 +03:00
|
|
|
event.state = 'confirmed'
|
2017-04-22 01:28:49 +05:30
|
|
|
event.event_schedules << build(:event_schedule, event: event, start_time: evaluator.hour)
|
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
|
2017-01-09 12:27:11 -06:00
|
|
|
|
|
|
|
|
factory :event_xss, parent: :event do
|
|
|
|
|
abstract { '<div id="divInjectedElement"></div>' }
|
|
|
|
|
end
|
2014-05-08 14:52:33 -07:00
|
|
|
end
|