osem-fcy/spec/factories/events.rb

80 lines
2.8 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2021-02-20 09:57:27 -08:00
# == Schema Information
#
# Table name: events
#
# id :bigint not null, primary key
# abstract :text
# comments_count :integer default(0), not null
2021-04-15 21:56:18 -07:00
# committee_review :text
2021-02-20 09:57:27 -08:00
# description :text
# guid :string not null
# is_highlight :boolean default(FALSE)
# language :string
# max_attendees :integer
# progress :string default("new"), not null
# proposal_additional_speakers :text
# public :boolean default(TRUE)
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
2021-02-26 11:04:20 -08:00
# submission_text :text
2021-02-20 09:57:27 -08:00
# subtitle :string
# title :string not null
# week :integer
# created_at :datetime
# updated_at :datetime
# difficulty_level_id :integer
# event_type_id :integer
# program_id :integer
# room_id :integer
# track_id :integer
#
FactoryBot.define do
factory :event do
2016-04-30 17:56:23 +02:00
title { Faker::Hipster.sentence }
abstract { Faker::Hipster.paragraph(2) }
program
after(:build) do |event|
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?
# 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
event.event_type ||= build(:event_type, program: event.program)
end
factory :event_full do
difficulty_level
after(:build) do |event|
event.commercials << build(:event_commercial, commercialable: event)
event.difficulty_level = build(:difficulty_level, program: event.program)
event.track = build(:track, program: event.program)
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)
end
2016-06-15 20:54:51 +03:00
factory :event_scheduled do
transient do
hour { nil }
end
after(:build) do |event, evaluator|
2016-06-15 20:54:51 +03:00
event.state = 'confirmed'
event.event_schedules << build(:event_schedule, event: event, start_time: evaluator.hour)
2016-06-15 20:54:51 +03:00
end
end
end
end
factory :event_xss, parent: :event do
abstract { '<div id="divInjectedElement"></div>' }
end
end