osem-fcy/spec/factories/conferences.rb

57 lines
2.5 KiB
Ruby
Raw Normal View History

2014-04-30 14:48:20 +02:00
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.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 { Date.today }
end_date { 6.days.from_now }
registration_limit 0
2016-05-02 15:56:40 +02:00
description { CGI.escapeHTML(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_attributes(schedule_public: true)
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(:campaign, conference: conference)
create(:target, conference: conference)
create(:question, conferences: [conference])
# Logo...
uploader = PictureUploader.new(conference, :picture)
File.open('app/assets/images/rails.png') { |f| uploader.store!(f) }
conference.logo_file_name = 'rails.png'
conference.save
end
end
end
end