2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2018-09-03 20:48:28 +02:00
|
|
|
# Read about factories at https://github.com/thoughtbot/factory_bot
|
2014-05-08 14:52:33 -07:00
|
|
|
|
2018-09-03 20:44:39 +02:00
|
|
|
FactoryBot.define do
|
2014-05-08 14:52:33 -07:00
|
|
|
factory :event do
|
2016-04-30 17:56:23 +02:00
|
|
|
title { Faker::Hipster.sentence }
|
2022-02-11 16:55:39 +01:00
|
|
|
abstract { Faker::Hipster.paragraph(sentence_count: 2) }
|
2016-04-30 17:56:23 +02:00
|
|
|
|
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
|
2018-09-08 03:58:50 +02:00
|
|
|
hour { nil }
|
2017-04-22 01:28:49 +05:30
|
|
|
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
|