diff --git a/app/models/contact.rb b/app/models/contact.rb index 4f904eeb..c2e3fd2d 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -3,8 +3,6 @@ class Contact < ActiveRecord::Base validates :conference, presence: true # Conferences only have one contact - validates :conference_id, uniqueness: {message: 'has already contact details'} - validates :facebook, :twitter, :googleplus, :instagram, format: URI::regexp(%w(http https)), allow_blank: true diff --git a/app/models/venue.rb b/app/models/venue.rb index 10cf4fcc..d0f5a005 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -6,7 +6,6 @@ class Venue < ActiveRecord::Base accepts_nested_attributes_for :commercial, allow_destroy: true validates :name, :street, :city, :country, presence: true - validates :conference_id, presence: true, uniqueness: true mount_uploader :picture, PictureUploader, mount_on: :photo_file_name @@ -32,7 +31,7 @@ class Venue < ActiveRecord::Base end 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 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 diff --git a/spec/factories/cfps.rb b/spec/factories/cfps.rb index 14b3fbc5..1ff58b9d 100644 --- a/spec/factories/cfps.rb +++ b/spec/factories/cfps.rb @@ -2,8 +2,9 @@ FactoryGirl.define do factory :cfp do - program start_date { 1.day.ago } end_date { 6.days.from_now } + + program end end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index a63dd0d5..c7c07bb8 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -2,12 +2,13 @@ FactoryGirl.define do factory :conference do - title 'The dog and pony show' - sequence(:short_title) { |n| "dps#{n}14" } - timezone 'Amsterdam' + 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 + 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)') @@ -17,19 +18,38 @@ FactoryGirl.define do end factory :full_conference do - splashpage + association :splashpage, factory: :full_splashpage registration_period + venue after :create do |conference| - create(:venue, conference_id: conference.id) conference.commercials << create(:conference_commercial, commercialable: conference) - conference.campaigns << create(:campaign, conference: conference) - conference.targets << create(:target, conference: conference) - conference.questions << create(:question, conference_id: conference.id) - conference.lodgings << create(:lodging, conference: conference) - conference.sponsors << create(:sponsor, conference: conference) - conference.sponsorship_levels << create(:sponsorship_level, conference: conference) - conference.tickets << create(:ticket, conference: conference) + + # 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 diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb new file mode 100644 index 00000000..9168f22b --- /dev/null +++ b/spec/factories/contacts.rb @@ -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 diff --git a/spec/factories/events.rb b/spec/factories/events.rb index f3999da8..e4cf19df 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -2,34 +2,11 @@ FactoryGirl.define do factory :event do - sequence(:title) { |n| "The ##{n} talk you'll ever attend." } - program - abstract <<-EOS - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ante - 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. + title { Faker::Hipster.sentence } + abstract { Faker::Hipster.paragraph(2) } + + program - 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| 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. diff --git a/spec/factories/lodgings.rb b/spec/factories/lodgings.rb index 2fee64c6..636d9060 100644 --- a/spec/factories/lodgings.rb +++ b/spec/factories/lodgings.rb @@ -2,9 +2,8 @@ FactoryGirl.define do factory :lodging do - name 'Example Hotel' - description 'Lorem Ipsum Dolor' - website_link 'http://www.example.com' - conference + name { "#{Faker::App.name} Hotel" } + description { Faker::Lorem.paragraph } + website_link { Faker::Internet.url } end end diff --git a/spec/factories/question.rb b/spec/factories/question.rb index 9bb933cb..ecbeceac 100644 --- a/spec/factories/question.rb +++ b/spec/factories/question.rb @@ -2,11 +2,9 @@ FactoryGirl.define do factory :question do - title 'blah' + title { Faker::Lorem.sentence } question_type - after(:build) do |question| - question.answers << build(:answer) - question.conferences << build(:conference) - end + conferences { [create(:conference)] } + answers { [create(:answer) ] } end end diff --git a/spec/factories/registration_periods.rb b/spec/factories/registration_periods.rb index 2a57baa8..bb775aa9 100644 --- a/spec/factories/registration_periods.rb +++ b/spec/factories/registration_periods.rb @@ -2,8 +2,7 @@ FactoryGirl.define do factory :registration_period do - start_date { 3.days.from_now } + start_date { 3.days.ago } end_date { 5.days.from_now } - conference end end diff --git a/spec/factories/rooms.rb b/spec/factories/rooms.rb index 7e610ad5..7347b95d 100644 --- a/spec/factories/rooms.rb +++ b/spec/factories/rooms.rb @@ -1,8 +1,9 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :room do - name 'Example Room' + name { "Room #{Faker::Address.country}" } size 4 + venue factory :room_for_100 do diff --git a/spec/factories/splashpages.rb b/spec/factories/splashpages.rb index 2d6ea303..752a36f3 100644 --- a/spec/factories/splashpages.rb +++ b/spec/factories/splashpages.rb @@ -3,5 +3,18 @@ FactoryGirl.define do factory :splashpage do 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 diff --git a/spec/factories/sponsors.rb b/spec/factories/sponsors.rb index 51fcc183..dd074ab3 100644 --- a/spec/factories/sponsors.rb +++ b/spec/factories/sponsors.rb @@ -2,16 +2,17 @@ FactoryGirl.define do factory :sponsor do - name 'Example sponsor' - website_url 'http://www.example.com' - description 'Lorem Ipsum Dolor' + name { Faker::Company.name } + website_url { Faker::Internet.url } + description { Faker::Lorem.paragraph } + sponsorship_level - conference after(:create) do |sponsor| + logo = "#{1 + rand(13)}.png" uploader = PictureUploader.new(sponsor, :picture) - File.open('app/assets/images/rails.png') { |f| uploader.store!(f) } - sponsor.logo_file_name = 'rails.png' + File.open("spec/support/logos/#{logo}") { |f| uploader.store!(f) } + sponsor.logo_file_name = logo.to_s sponsor.save end end diff --git a/spec/factories/sponsorship_levels.rb b/spec/factories/sponsorship_levels.rb index d13ea48a..a6702f6e 100644 --- a/spec/factories/sponsorship_levels.rb +++ b/spec/factories/sponsorship_levels.rb @@ -2,7 +2,8 @@ FactoryGirl.define do factory :sponsorship_level do - title 'Platin' + title { Faker::Hipster.word } + conference end end diff --git a/spec/factories/tickets.rb b/spec/factories/tickets.rb index 1e3105cc..88532b86 100644 --- a/spec/factories/tickets.rb +++ b/spec/factories/tickets.rb @@ -1,8 +1,7 @@ FactoryGirl.define do factory :ticket do - title 'Business Ticket' + title { "#{Faker::Hipster.word} Ticket" } price_cents 1000 price_currency 'USD' - conference end end diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index 03167789..3f35f539 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -1,9 +1,7 @@ FactoryGirl.define do factory :track do - name 'Example Track' - description 'Lorem Ipsum dolsum' - color '#ffffff' - program + name { Faker::Commerce.department(2, true) } + description { Faker::Lorem.sentence } + color { Faker::Color.hex_color } end - end diff --git a/spec/factories/venues.rb b/spec/factories/venues.rb index 31aa64e9..11f27035 100644 --- a/spec/factories/venues.rb +++ b/spec/factories/venues.rb @@ -1,13 +1,14 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :venue do - name 'Suse Office' - street 'Maxfeldstrasse 5' - city 'Nuremberg' - postalcode '90489' - country 'DE' - website 'www.opensuse.org' - description 'Lorem Ipsum Dolor' + name { "#{Faker::Company.name} Office" } + street { Faker::Address.street_address } + city { Faker::Address.city } + postalcode { Faker::Address.postcode } + country { Faker::Address.country_code } + website { Faker::Internet.url } + description { Faker::Lorem.sentence } + conference end end diff --git a/spec/support/logos/1.png b/spec/support/logos/1.png new file mode 100644 index 00000000..c74d3f65 Binary files /dev/null and b/spec/support/logos/1.png differ diff --git a/spec/support/logos/10.png b/spec/support/logos/10.png new file mode 100644 index 00000000..8e65fd80 Binary files /dev/null and b/spec/support/logos/10.png differ diff --git a/spec/support/logos/11.png b/spec/support/logos/11.png new file mode 100644 index 00000000..05d8f020 Binary files /dev/null and b/spec/support/logos/11.png differ diff --git a/spec/support/logos/12.png b/spec/support/logos/12.png new file mode 100644 index 00000000..0c3c108c Binary files /dev/null and b/spec/support/logos/12.png differ diff --git a/spec/support/logos/13.png b/spec/support/logos/13.png new file mode 100644 index 00000000..9d2a863d Binary files /dev/null and b/spec/support/logos/13.png differ diff --git a/spec/support/logos/2.png b/spec/support/logos/2.png new file mode 100644 index 00000000..7c09a2a4 Binary files /dev/null and b/spec/support/logos/2.png differ diff --git a/spec/support/logos/3.png b/spec/support/logos/3.png new file mode 100644 index 00000000..02158c21 Binary files /dev/null and b/spec/support/logos/3.png differ diff --git a/spec/support/logos/4.png b/spec/support/logos/4.png new file mode 100644 index 00000000..8743e9fb Binary files /dev/null and b/spec/support/logos/4.png differ diff --git a/spec/support/logos/5.png b/spec/support/logos/5.png new file mode 100644 index 00000000..af26fe82 Binary files /dev/null and b/spec/support/logos/5.png differ diff --git a/spec/support/logos/6.png b/spec/support/logos/6.png new file mode 100644 index 00000000..648e88fc Binary files /dev/null and b/spec/support/logos/6.png differ diff --git a/spec/support/logos/7.png b/spec/support/logos/7.png new file mode 100644 index 00000000..4de213a0 Binary files /dev/null and b/spec/support/logos/7.png differ diff --git a/spec/support/logos/8.png b/spec/support/logos/8.png new file mode 100644 index 00000000..659d3273 Binary files /dev/null and b/spec/support/logos/8.png differ diff --git a/spec/support/logos/9.png b/spec/support/logos/9.png new file mode 100644 index 00000000..23f75ae0 Binary files /dev/null and b/spec/support/logos/9.png differ diff --git a/spec/support/logos/README.md b/spec/support/logos/README.md new file mode 100644 index 00000000..6c5ba321 --- /dev/null +++ b/spec/support/logos/README.md @@ -0,0 +1 @@ +These are fake logos from https://github.com/pigment/fake-logos