Make use of fake data in factories
|
|
@ -3,8 +3,6 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
validates :conference, presence: true
|
validates :conference, presence: true
|
||||||
# Conferences only have one contact
|
# Conferences only have one contact
|
||||||
validates :conference_id, uniqueness: {message: 'has already contact details'}
|
|
||||||
|
|
||||||
validates :facebook, :twitter, :googleplus, :instagram,
|
validates :facebook, :twitter, :googleplus, :instagram,
|
||||||
format: URI::regexp(%w(http https)), allow_blank: true
|
format: URI::regexp(%w(http https)), allow_blank: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ class Venue < ActiveRecord::Base
|
||||||
|
|
||||||
accepts_nested_attributes_for :commercial, allow_destroy: true
|
accepts_nested_attributes_for :commercial, allow_destroy: true
|
||||||
validates :name, :street, :city, :country, presence: true
|
validates :name, :street, :city, :country, presence: true
|
||||||
validates :conference_id, presence: true, uniqueness: true
|
|
||||||
|
|
||||||
mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
|
mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
|
||||||
|
|
||||||
|
|
@ -32,7 +31,7 @@ class Venue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_on_venue_changed?
|
def notify_on_venue_changed?
|
||||||
return false unless conference.email_settings.send_on_venue_updated
|
return false unless conference.try(:email_settings).try(:send_on_venue_updated)
|
||||||
# do not notify unless the address changed
|
# do not notify unless the address changed
|
||||||
return false unless self.name_changed? || self.street_changed? || self.city_changed? || self.country_changed?
|
return false unless self.name_changed? || self.street_changed? || self.city_changed? || self.country_changed?
|
||||||
# do not notify unless the mail content is set up
|
# do not notify unless the mail content is set up
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :cfp do
|
factory :cfp do
|
||||||
program
|
|
||||||
start_date { 1.day.ago }
|
start_date { 1.day.ago }
|
||||||
end_date { 6.days.from_now }
|
end_date { 6.days.from_now }
|
||||||
|
|
||||||
|
program
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :conference do
|
factory :conference do
|
||||||
title 'The dog and pony show'
|
title { Faker::Book.title }
|
||||||
sequence(:short_title) { |n| "dps#{n}14" }
|
short_title { SecureRandom.urlsafe_base64(4) }
|
||||||
timezone 'Amsterdam'
|
timezone { Faker::Address.time_zone }
|
||||||
start_date { Date.today }
|
start_date { Date.today }
|
||||||
end_date { 6.days.from_now }
|
end_date { 6.days.from_now }
|
||||||
registration_limit 0
|
registration_limit 0
|
||||||
|
description { Faker::Hipster.paragraph }
|
||||||
|
|
||||||
after(:create) do |conference|
|
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: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)')
|
||||||
|
|
@ -17,19 +18,38 @@ FactoryGirl.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :full_conference do
|
factory :full_conference do
|
||||||
splashpage
|
association :splashpage, factory: :full_splashpage
|
||||||
registration_period
|
registration_period
|
||||||
|
venue
|
||||||
|
|
||||||
after :create do |conference|
|
after :create do |conference|
|
||||||
create(:venue, conference_id: conference.id)
|
|
||||||
conference.commercials << create(:conference_commercial, commercialable: conference)
|
conference.commercials << create(:conference_commercial, commercialable: conference)
|
||||||
conference.campaigns << create(:campaign, conference: conference)
|
|
||||||
conference.targets << create(:target, conference: conference)
|
# Contact/Program is created by Conference callbacks
|
||||||
conference.questions << create(:question, conference_id: conference.id)
|
conference.contact.destroy
|
||||||
conference.lodgings << create(:lodging, conference: conference)
|
conference.contact = create(:contact, conference: conference)
|
||||||
conference.sponsors << create(:sponsor, conference: conference)
|
conference.program.update_attributes(schedule_public: true)
|
||||||
conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
|
|
||||||
conference.tickets << create(:ticket, conference: conference)
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
13
spec/factories/contacts.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :contact do
|
||||||
|
social_tag { SecureRandom.urlsafe_base64(4) }
|
||||||
|
email { Faker::Internet.email }
|
||||||
|
sponsor_email { Faker::Internet.email }
|
||||||
|
facebook { Faker::Internet.url('facebook.com') }
|
||||||
|
googleplus { Faker::Internet.url('plus.google.com') }
|
||||||
|
twitter { Faker::Internet.url('twitter.com') }
|
||||||
|
instagram { Faker::Internet.url('instagram.com') }
|
||||||
|
|
||||||
|
conference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -2,34 +2,11 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :event do
|
factory :event do
|
||||||
sequence(:title) { |n| "The ##{n} talk you'll ever attend." }
|
title { Faker::Hipster.sentence }
|
||||||
program
|
abstract { Faker::Hipster.paragraph(2) }
|
||||||
abstract <<-EOS
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ante
|
program
|
||||||
lacus, mollis non urna vitae, varius semper leo. Nulla ac nibh dui. Mauris
|
|
||||||
convallis diam eu porta fermentum. Vestibulum posuere odio et est ornare,
|
|
||||||
at consectetur ante eleifend. Etiam tellus libero, ornare at euismod nec,
|
|
||||||
luctus a leo. Aliquam et commodo lacus, at luctus nibh. Aenean eleifend
|
|
||||||
risus a nisi pellentesque tempor. Etiam dapibus facilisis odio at ornare.
|
|
||||||
Mauris tempus, nunc ut malesuada iaculis, eros mi mattis ligula, vitae
|
|
||||||
lobortis enim lacus ut nunc. Donec mattis sagittis imperdiet.
|
|
||||||
Pellentesque ultrices malesuada ipsum, mattis dignissim felis pulvinar
|
|
||||||
vitae. Etiam ultrices erat convallis arcu placerat, at vulputate felis
|
|
||||||
tempus. Ut eleifend sem et ante feugiat euismod ac luctus tortor. Nam
|
|
||||||
commodo mattis erat ac condimentum. Duis dictum tempus odio, quis
|
|
||||||
adipiscing justo. Etiam nunc neque, rutrum vitae sapien eget, elementum
|
|
||||||
dignissim dui.
|
|
||||||
|
|
||||||
Donec vitae laoreet augue. Sed eget felis placerat, scelerisque felis eu,
|
|
||||||
mattis risus. Sed posuere arcu at lacus ultricies pretium. Aenean in
|
|
||||||
dapibus erat. Morbi vitae risus eu ante lacinia mollis. Donec vitae
|
|
||||||
hendrerit est. Maecenas ac sem non mi vulputate aliquam ac eget enim.
|
|
||||||
Curabitur eget volutpat nisi. Proin sit amet consequat urna. Aliquam nec
|
|
||||||
elit vitae tellus pellentesque ultricies. Sed in enim vitae nisl
|
|
||||||
ullamcorper dignissim. Proin aliquet nisi sed mauris dapibus, sit amet
|
|
||||||
dignissim quam pulvinar. Nunc dictum porta sodales. Cras ullamcorper
|
|
||||||
libero quis porta ultricies. Fusce pulvinar accumsan lobortis.
|
|
||||||
EOS
|
|
||||||
after(:build) do |event|
|
after(:build) do |event|
|
||||||
event.event_users << build(:submitter) unless event.submitter # so that we don't have two submitters
|
event.event_users << build(:submitter) unless event.submitter # so that we don't have two submitters
|
||||||
# set an event_type if none is passed to the factory.
|
# set an event_type if none is passed to the factory.
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :lodging do
|
factory :lodging do
|
||||||
name 'Example Hotel'
|
name { "#{Faker::App.name} Hotel" }
|
||||||
description 'Lorem Ipsum Dolor'
|
description { Faker::Lorem.paragraph }
|
||||||
website_link 'http://www.example.com'
|
website_link { Faker::Internet.url }
|
||||||
conference
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :question do
|
factory :question do
|
||||||
title 'blah'
|
title { Faker::Lorem.sentence }
|
||||||
question_type
|
question_type
|
||||||
after(:build) do |question|
|
conferences { [create(:conference)] }
|
||||||
question.answers << build(:answer)
|
answers { [create(:answer) ] }
|
||||||
question.conferences << build(:conference)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :registration_period do
|
factory :registration_period do
|
||||||
start_date { 3.days.from_now }
|
start_date { 3.days.ago }
|
||||||
end_date { 5.days.from_now }
|
end_date { 5.days.from_now }
|
||||||
conference
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :room do
|
factory :room do
|
||||||
name 'Example Room'
|
name { "Room #{Faker::Address.country}" }
|
||||||
size 4
|
size 4
|
||||||
|
|
||||||
venue
|
venue
|
||||||
|
|
||||||
factory :room_for_100 do
|
factory :room_for_100 do
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,18 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :splashpage do
|
factory :splashpage do
|
||||||
public false
|
public false
|
||||||
|
|
||||||
|
factory :full_splashpage do
|
||||||
|
public true
|
||||||
|
include_tracks true
|
||||||
|
include_program true
|
||||||
|
include_social_media true
|
||||||
|
include_venue true
|
||||||
|
include_tickets true
|
||||||
|
include_registrations true
|
||||||
|
include_sponsors true
|
||||||
|
include_lodgings true
|
||||||
|
include_cfp true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :sponsor do
|
factory :sponsor do
|
||||||
name 'Example sponsor'
|
name { Faker::Company.name }
|
||||||
website_url 'http://www.example.com'
|
website_url { Faker::Internet.url }
|
||||||
description 'Lorem Ipsum Dolor'
|
description { Faker::Lorem.paragraph }
|
||||||
|
|
||||||
sponsorship_level
|
sponsorship_level
|
||||||
conference
|
|
||||||
|
|
||||||
after(:create) do |sponsor|
|
after(:create) do |sponsor|
|
||||||
|
logo = "#{1 + rand(13)}.png"
|
||||||
uploader = PictureUploader.new(sponsor, :picture)
|
uploader = PictureUploader.new(sponsor, :picture)
|
||||||
File.open('app/assets/images/rails.png') { |f| uploader.store!(f) }
|
File.open("spec/support/logos/#{logo}") { |f| uploader.store!(f) }
|
||||||
sponsor.logo_file_name = 'rails.png'
|
sponsor.logo_file_name = logo.to_s
|
||||||
sponsor.save
|
sponsor.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :sponsorship_level do
|
factory :sponsorship_level do
|
||||||
title 'Platin'
|
title { Faker::Hipster.word }
|
||||||
|
|
||||||
conference
|
conference
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :ticket do
|
factory :ticket do
|
||||||
title 'Business Ticket'
|
title { "#{Faker::Hipster.word} Ticket" }
|
||||||
price_cents 1000
|
price_cents 1000
|
||||||
price_currency 'USD'
|
price_currency 'USD'
|
||||||
conference
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :track do
|
factory :track do
|
||||||
name 'Example Track'
|
name { Faker::Commerce.department(2, true) }
|
||||||
description 'Lorem Ipsum dolsum'
|
description { Faker::Lorem.sentence }
|
||||||
color '#ffffff'
|
color { Faker::Color.hex_color }
|
||||||
program
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :venue do
|
factory :venue do
|
||||||
name 'Suse Office'
|
name { "#{Faker::Company.name} Office" }
|
||||||
street 'Maxfeldstrasse 5'
|
street { Faker::Address.street_address }
|
||||||
city 'Nuremberg'
|
city { Faker::Address.city }
|
||||||
postalcode '90489'
|
postalcode { Faker::Address.postcode }
|
||||||
country 'DE'
|
country { Faker::Address.country_code }
|
||||||
website 'www.opensuse.org'
|
website { Faker::Internet.url }
|
||||||
description 'Lorem Ipsum Dolor'
|
description { Faker::Lorem.sentence }
|
||||||
|
|
||||||
conference
|
conference
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
BIN
spec/support/logos/1.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
spec/support/logos/10.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
spec/support/logos/11.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
spec/support/logos/12.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
spec/support/logos/13.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
spec/support/logos/2.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
spec/support/logos/3.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
spec/support/logos/4.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
spec/support/logos/5.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
spec/support/logos/6.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
spec/support/logos/7.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
spec/support/logos/8.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
spec/support/logos/9.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
1
spec/support/logos/README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
These are fake logos from https://github.com/pigment/fake-logos
|
||||||