osem-fcy/spec/factories/conferences.rb

59 lines
2.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-09-03 20:48:28 +02:00
# Read about factories at https://github.com/thoughtbot/factory_bot
2014-04-30 14:48:20 +02:00
FactoryBot.define do
factory :conference do
2016-04-30 17:56:23 +02:00
title { Faker::Book.title }
short_title { SecureRandom.urlsafe_base64(4) }
timezone { Faker::Address.time_zone }
start_date { Time.zone.today }
end_date { 6.days.from_now }
start_hour { 9 }
end_hour { 20 }
registration_limit { 0 }
ticket_layout { 'portrait' }
2016-05-02 17:39:06 +02:00
description { Faker::Hipster.paragraph }
after(:create) do |conference|
Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)')
Role.where(name: 'cfp', resource: conference).first_or_create(description: 'For the members of the CfP team')
Role.where(name: 'info_desk', resource: conference).first_or_create(description: 'For the members of the Info Desk team')
Role.where(name: 'volunteers_coordinator', resource: conference).first_or_create(description: 'For the people in charge of volunteers')
end
factory :full_conference do
2016-04-30 17:56:23 +02:00
association :splashpage, factory: :full_splashpage
registration_period
2016-04-30 17:56:23 +02:00
venue
2015-11-07 11:43:36 +02:00
after :create do |conference|
conference.commercials << create(:conference_commercial, commercialable: conference)
2016-04-30 17:56:23 +02:00
# Contact/Program is created by Conference callbacks
conference.contact.destroy
conference.contact = create(:contact, conference: conference)
conference.program.update_attribute(:schedule_public, true)
2016-04-30 17:56:23 +02:00
create(:cfp, program: conference.program)
create_list(:track, 2, program: conference.program)
create_list(:ticket, 3, conference: conference)
create_list(:room, 3, venue: conference.venue)
create_list(:lodging, 4, conference: conference)
create_list(:sponsorship_level, 3, conference: conference)
create(:sponsor, sponsorship_level: conference.sponsorship_levels.first, conference: conference)
create_list(:sponsor, 2, sponsorship_level: conference.sponsorship_levels.second, conference: conference)
create_list(:sponsor, 3, sponsorship_level: conference.sponsorship_levels.third, conference: conference)
create(:question, conferences: [conference])
# Logo...
File.open('spec/support/logos/OSEM.jpg') do |file|
conference.picture = file
end
conference.save!
end
end
end
end