diff --git a/Gemfile b/Gemfile index 93505e29..cd0ac861 100644 --- a/Gemfile +++ b/Gemfile @@ -174,13 +174,17 @@ gem 'cloudinary' # for setting app configuration in the environment gem 'dotenv-rails' +# for fake data +# this is not in a group as we use it also for rake data:demo +gem 'faker' + # Use guard and spring for testing in development group :development do # to launch specs when files are modified gem 'guard-rspec', '~> 4.2.8' gem 'spring-commands-rspec' # for static code analisys - gem 'rubocop' + gem 'rubocop', require: false # to silence rack assests messages gem 'quiet_assets' # as database diff --git a/Gemfile.lock b/Gemfile.lock index 95f4f966..ef102920 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -173,6 +173,8 @@ GEM factory_girl_rails (4.6.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) + faker (1.6.1) + i18n (~> 0.5) faraday (0.9.0) multipart-post (>= 1.2, < 3) fastimage (2.0.0) @@ -550,6 +552,7 @@ DEPENDENCIES devise_ichain_authenticatable dotenv-rails factory_girl_rails + faker font-awesome-rails formtastic (~> 3.1.1) formtastic-bootstrap diff --git a/app/models/cfp.rb b/app/models/cfp.rb index 706e376b..3cd15bf7 100644 --- a/app/models/cfp.rb +++ b/app/models/cfp.rb @@ -3,7 +3,7 @@ class Cfp < ActiveRecord::Base belongs_to :program - validates :program_id, presence: true, uniqueness: true + validates :program_id, presence: true validates :start_date, :end_date, presence: true validate :before_end_of_conference validate :start_after_end_date 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/app/views/conference/_call_for_paper.html.haml b/app/views/conference/_call_for_paper.html.haml index a1e6ca4e..44d8a983 100644 --- a/app/views/conference/_call_for_paper.html.haml +++ b/app/views/conference/_call_for_paper.html.haml @@ -12,24 +12,24 @@ .row .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 %p - - if @program.event_types.any? + - if @conference.program.event_types.any? You can submit proposals for %span.notranslate = "#{event_types(@conference)}." - - if @program.tracks.any? + - if @conference.program.tracks.any? Proposals should fit in one of the %span.notranslate - = "#{pluralize(@program.tracks.count, 'track')}:" + = "#{pluralize(@conference.program.tracks.count, 'track')}:" = "#{tracks(@conference)}." The submission period has begun %em.notranslate - = @program.cfp.start_date.strftime('%A, %B %-d. %Y') + = @conference.program.cfp.start_date.strftime('%A, %B %-d. %Y') and closes %em.notranslate - = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') - - if @program.cfp_open? + = @conference.program.cfp.end_date.strftime('%A, %B %-d. %Y.') + - if @conference.program.cfp_open? That means you have only - %b.notranslate= pluralize(@program.cfp.remaining_days, 'day') + %b.notranslate= pluralize(@conference.program.cfp.remaining_days, 'day') left! Remember %span.notranslate diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 071f8f7a..90a9b4eb 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -36,7 +36,7 @@ %section#program = render 'schedule_splashpage' - - if @program.cfp_open? and @conference.splashpage.include_cfp + - if @conference.program.cfp_open? and @conference.splashpage.include_cfp %section#callforpapers = render 'call_for_paper' diff --git a/lib/tasks/data_demo.rake b/lib/tasks/data_demo.rake new file mode 100644 index 00000000..dc209c1d --- /dev/null +++ b/lib/tasks/data_demo.rake @@ -0,0 +1,8 @@ +namespace :data do + desc 'Create demo data using our factories' + task demo: :environment do + include FactoryGirl::Syntax::Methods + create(:full_conference) + create(:admin, email: 'admin@osem.io', username: 'admin', password: 'password', password_confirmation: 'password') + end +end diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 9ad97cac..2384c909 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -58,7 +58,7 @@ describe Admin::ConferenceController do conference.reload expect(flash[:error]). to eq("Updating conference failed. Short title can't be blank.") - expect(conference.title).to eq('The dog and pony show') + expect(conference.title).to eq("#{conference.title}") expect(conference.short_title).to eq("#{conference.short_title}") end diff --git a/spec/controllers/conference_registration_controller_spec.rb b/spec/controllers/conference_registration_controller_spec.rb index 54a6c4bd..3071a38c 100644 --- a/spec/controllers/conference_registration_controller_spec.rb +++ b/spec/controllers/conference_registration_controller_spec.rb @@ -114,7 +114,7 @@ describe ConferenceRegistrationsController, type: :controller do end it 'shows error in flash message' do - expect(flash[:error]).to match "Could not update your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}." + expect(flash[:error]).to match "Could not update your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}." end it 'does not update the registration' do @@ -139,7 +139,7 @@ describe ConferenceRegistrationsController, type: :controller do end it 'shows success message in flash notice', run: true do - expect(flash[:notice]).to match('You are not registered for The dog and pony show anymore!') + expect(flash[:notice]).to match("You are not registered for #{conference.title} anymore!") end it 'deletes the registration' do @@ -160,7 +160,7 @@ describe ConferenceRegistrationsController, type: :controller do end it 'shows error in flash message' do - expect(flash[:error]).to match "Could not delete your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}." + expect(flash[:error]).to match "Could not delete your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}." end it 'does not delete the registration' do 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..3bd59f64 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 { 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)') @@ -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..73ceeefa 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 { CGI.escapeHTML(Faker::Lorem.paragraph) } + website_link { Faker::Internet.url } end end diff --git a/spec/factories/question.rb b/spec/factories/question.rb index 9bb933cb..5a2a58e5 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..edf1bf16 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 { CGI.escapeHTML(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..df2e3b6d 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/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index 0731eff6..6d1d72ff 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -35,13 +35,13 @@ feature Lodging do visit admin_conference_lodgings_path( conference_id: conference.short_title) - expect(page.has_content?('Example Hotel')).to be true + expect(page.has_content?(lodging.name)).to be true # Add lodging click_link 'Edit' fill_in 'lodging_name', with: 'New lodging' - fill_in 'lodging_website_link', with: 'http:\\www.google.com' + fill_in 'lodging_website_link', with: 'http://www.google.com' attach_file 'Picture', path click_button 'Update Lodging' @@ -51,26 +51,26 @@ feature Lodging do expect(page.has_content?('New lodging')).to be true lodging.reload expect(lodging.name).to eq('New lodging') - expect(lodging.description).to eq('Lorem Ipsum Dolor') - expect(lodging.website_link).to eq('http:\\www.google.com') + expect(lodging.description).to eq(lodging.description) + expect(lodging.website_link).to eq('http://www.google.com') expect(Lodging.count).to eq(1) end scenario 'Delete a lodging', feature: true, js: true do - conference.lodgings << create(:lodging) + lodging = create(:lodging, conference: conference) sign_in organizer visit admin_conference_lodgings_path( conference_id: conference.short_title) - expect(page.has_content?('Example Hotel')).to be true + expect(page.has_content?(lodging.name)).to be true # Add lodging click_link 'Delete' # Validations expect(flash).to eq('Lodging successfully deleted.') - expect(page.has_content?('Example Hotel')).to be false + expect(page.has_content?(lodging.name)).to be false expect(Lodging.count).to eq(0) end end diff --git a/spec/features/sponsor_spec.rb b/spec/features/sponsor_spec.rb index df527ede..c6b5009e 100644 --- a/spec/features/sponsor_spec.rb +++ b/spec/features/sponsor_spec.rb @@ -21,7 +21,7 @@ feature Sponsor do fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution' attach_file 'Picture', path fill_in 'sponsor_website_url', with: 'http://www.suse.com' - select('Platin', from: 'sponsor_sponsorship_level_id') + select(conference.sponsorship_levels.first.title, from: 'sponsor_sponsorship_level_id') click_button 'Create Sponsor' @@ -30,7 +30,7 @@ feature Sponsor do expect(page.has_content?('SUSE')).to be true expect(page.has_content?('The original provider')).to be true expect(page.has_content?('http://www.suse.com')).to be true - expect(page.has_content?('Platin')).to be true + expect(page.has_content?(conference.sponsorship_levels.first.title)).to be true expect(page).to have_selector("img[src*='rails.png']") expect(page.assert_selector('tr', count: 2)).to be true end diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index b8c8ecbe..e3ae1e09 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -33,7 +33,7 @@ feature Registration do expect(current_path).to eq(conference_conference_registrations_path(conference.short_title)) expect(flash). to eq("Thank you for supporting #{conference.title} by purchasing a ticket.") - expect(page.has_content?('2 Business Ticket Tickets for 10')).to be true + expect(page.has_content?("2 #{ticket.title} Tickets for 10")).to be true end scenario 'deletes a purchased ticket', feature: true, js: true do @@ -41,7 +41,7 @@ feature Registration do create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4) visit conference_conference_registrations_path(conference.short_title) - expect(page.has_content?('4 Business Ticket Tickets for 10')).to be true + expect(page.has_content?("4 #{ticket.title} Tickets for 10")).to be true click_link "ticket-#{ticket.id}-delete" expect(flash).to eq('Ticket successfully deleted.') diff --git a/spec/helpers/sponsor_helper_spec.rb b/spec/helpers/sponsor_helper_spec.rb index ec9aff06..c6ce08ce 100644 --- a/spec/helpers/sponsor_helper_spec.rb +++ b/spec/helpers/sponsor_helper_spec.rb @@ -11,7 +11,7 @@ describe SponsorsHelper, type: :helper do end it 'returns correct url' do - expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.png\b)} + expect(get_logo(sponsor)).to match %r{.*(\bfirst/#{sponsor.logo_file_name}\b)} end end @@ -22,7 +22,7 @@ describe SponsorsHelper, type: :helper do end it 'returns correct url' do - expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.png\b)} + expect(get_logo(sponsor)).to match %r{.*(\bsecond/#{sponsor.logo_file_name}\b)} end end @@ -33,7 +33,7 @@ describe SponsorsHelper, type: :helper do end it 'returns correct url' do - expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.png\b)} + expect(get_logo(sponsor)).to match %r{.*(\bothers/#{sponsor.logo_file_name}\b)} end end end diff --git a/spec/models/email_settings_spec.rb b/spec/models/email_settings_spec.rb index a649ab92..8392d056 100644 --- a/spec/models/email_settings_spec.rb +++ b/spec/models/email_settings_spec.rb @@ -9,7 +9,7 @@ describe EmailSettings do { 'email' => 'john@doe.com', 'name' => 'John Doe', - 'conference' => 'The dog and pony show', + 'conference' => conference.title, 'conference_start_date' => Date.new(2014, 05, 01), 'conference_end_date' => Date.new(2014, 05, 06), 'registrationlink' => 'http://localhost:3000/conference/goto/register', @@ -62,7 +62,7 @@ describe EmailSettings do context 'conference has venue' do before do conference.update_attributes(venue: create(:venue)) - venue_hash = { 'venue' => 'Suse Office', 'venue_address' => 'Maxfeldstrasse 5, Nuremberg, Germany' } + venue_hash = { 'venue' => conference.venue.name, 'venue_address' => conference.venue.address } expected_hash.merge!(venue_hash) end @@ -105,7 +105,7 @@ describe EmailSettings do it 'replaces fillers in template' do expected_text = "Dear John Doe\n\nWe are very pleased" \ - 'to inform you that your submission Talk about talks has been accepted for the conference The dog and pony show.' + "to inform you that your submission Talk about talks has been accepted for the conference #{conference.title}." expect(conference.email_settings.generate_event_mail(event, event_template)).to eq expected_text end end @@ -114,7 +114,7 @@ describe EmailSettings do let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." } it 'replaces fillers in template' do - expected_text = "Dear John Doe,\n\nThank you for Registering for the conference The dog and pony show." + expected_text = "Dear John Doe,\n\nThank you for Registering for the conference #{conference.title}." expect(conference.email_settings.generate_email_on_conf_updates(conference, user, conf_update_template)).to eq expected_text end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index e25dd354..6bbb416c 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -221,7 +221,7 @@ describe Event do describe '#abstract_word_count' do it 'counts words in abstract' do event = build(:event) - expect(event.abstract_word_count).to eq(233) + expect(event.abstract_word_count).to eq(event.abstract.to_s.split.size) event.update_attributes!(abstract: 'abstract.') expect(event.abstract_word_count).to eq(1) end diff --git a/spec/serializers/conference_serializer_spec.rb b/spec/serializers/conference_serializer_spec.rb index 1de2f887..20c28f7f 100644 --- a/spec/serializers/conference_serializer_spec.rb +++ b/spec/serializers/conference_serializer_spec.rb @@ -12,7 +12,7 @@ describe ConferenceSerializer, type: :serializer do { conference: { short_title: 'goto', - title: 'The dog and pony show', + title: conference.title, description: 'Lorem ipsum dolor sit', start_date: '2014-03-04', end_date: '2014-03-10', @@ -61,7 +61,7 @@ describe ConferenceSerializer, type: :serializer do before do venue = create(:venue, conference: conference) _room = create(:room, venue: venue) - _track = create(:track, program: conference.program) + track = create(:track, program: conference.program) room_hash = { rooms: [{ @@ -74,8 +74,8 @@ describe ConferenceSerializer, type: :serializer do track_hash = { tracks: [{ id: 1, - name: 'Example Track', - description: 'Lorem Ipsum dolsum' + name: track.name, + description: track.description } ] } diff --git a/spec/serializers/room_serializer_spec.rb b/spec/serializers/room_serializer_spec.rb index 6ec10985..5b7467cc 100644 --- a/spec/serializers/room_serializer_spec.rb +++ b/spec/serializers/room_serializer_spec.rb @@ -7,7 +7,7 @@ describe RoomSerializer, type: :serializer do expected_json = { room: { guid: room.guid, - name: 'Example Room', + name: room.name, description: '' } }.to_json diff --git a/spec/serializers/track_serializer_spec.rb b/spec/serializers/track_serializer_spec.rb index 856a593c..00522eae 100644 --- a/spec/serializers/track_serializer_spec.rb +++ b/spec/serializers/track_serializer_spec.rb @@ -8,8 +8,8 @@ describe TrackSerializer, type: :serializer do expected_json = { track: { guid: track.guid, - name: 'Example Track', - color: '#ffffff' + name: track.name, + color: track.color } }.to_json 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 diff --git a/spec/support/save_feature_failures.rb b/spec/support/save_feature_failures.rb index 4cfb68d4..fe6edf66 100644 --- a/spec/support/save_feature_failures.rb +++ b/spec/support/save_feature_failures.rb @@ -1,18 +1,17 @@ -# Automatically save and open the page -# whenever an expectation is not met in a features spec +# Automatically save the page a test fails +Capybara.save_and_open_page_path = Rails.root.join('tmp', 'capybara') + RSpec.configure do |config| config.after(:each, type: :feature) do - ename = RSpec.current_example.full_description - ename = ename.gsub ' ', '_' - ename.downcase! - ename = ename + '.html' + example_filename = RSpec.current_example.full_description + example_filename = example_filename.tr(' ', '_') + example_filename = example_filename + '.html' + example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path) if RSpec.current_example.exception.present? - save_page(ename) - else - capfile = File.expand_path(ename, Capybara.save_and_open_page_path) - if File.exist?(capfile) - File.unlink(capfile) - end + save_page(example_filename) + # remove the file if the test starts working again + elsif File.exist?(example_filename) + File.unlink(example_filename) end end end diff --git a/spec/views/admin/conference/index.html.haml_spec.rb b/spec/views/admin/conference/index.html.haml_spec.rb index 99280fd0..b2c285cb 100644 --- a/spec/views/admin/conference/index.html.haml_spec.rb +++ b/spec/views/admin/conference/index.html.haml_spec.rb @@ -1,10 +1,13 @@ require 'spec_helper' describe 'admin/conference/index' do + let(:conference) { create(:conference, title: 'openSUSE Conference 2016') } + let(:second_conference) { create(:conference) } + it 'renders all conference names with links' do - assign(:conferences, [create(:conference, title: 'openSUSE'), create(:conference)]) + assign(:conferences, [conference, second_conference]) render - expect(rendered).to include('openSUSE') - expect(rendered).to include('The dog and pony show') + expect(rendered).to include('openSUSE Conference 2016') + expect(rendered).to include(second_conference.title) end end diff --git a/spec/views/admin/conference/new.html.haml_spec.rb b/spec/views/admin/conference/new.html.haml_spec.rb index ebcd8a78..e19ab1d3 100644 --- a/spec/views/admin/conference/new.html.haml_spec.rb +++ b/spec/views/admin/conference/new.html.haml_spec.rb @@ -1,12 +1,14 @@ require 'spec_helper' describe 'admin/conference/new' do + let(:conference) { build(:conference) } + it 'renders the new template for the conference' do assign(:conference, Conference.new) render expect(rendered).to include('Basic Information') - assign(:conference, build(:conference)) + assign(:conference, conference) render - expect(rendered).to include('The dog and pony show') + expect(rendered).to include(conference.title) end end diff --git a/spec/views/admin/lodgings/index.html.haml_spec.rb b/spec/views/admin/lodgings/index.html.haml_spec.rb index bb20da17..30fdaece 100644 --- a/spec/views/admin/lodgings/index.html.haml_spec.rb +++ b/spec/views/admin/lodgings/index.html.haml_spec.rb @@ -7,6 +7,6 @@ describe 'admin/lodgings/index' do @conference.lodgings << create(:lodging) assign :venue, @conference.venue render - expect(rendered).to include('Example Hotel') + expect(rendered).to include(@conference.lodgings.first.name) end end diff --git a/spec/views/admin/sponsors/index.html.haml_spec.rb b/spec/views/admin/sponsors/index.html.haml_spec.rb index 51b845ff..6311c5d1 100644 --- a/spec/views/admin/sponsors/index.html.haml_spec.rb +++ b/spec/views/admin/sponsors/index.html.haml_spec.rb @@ -9,9 +9,9 @@ describe 'admin/sponsors/index' do ) assign :conference, @conference render - expect(rendered).to include('Example sponsor') - expect(rendered).to include('http://www.example.com') - expect(rendered).to include('Lorem Ipsum Dolor') - expect(rendered).to include('Platin') + expect(rendered).to include(@conference.sponsors.first.name) + expect(rendered).to include(@conference.sponsors.first.website_url) + expect(rendered).to include(truncate(@conference.sponsors.first.description)) + expect(rendered).to include(@conference.sponsorship_levels.first.title) end end diff --git a/spec/views/admin/sponsorship_levels/index.html.haml_spec.rb b/spec/views/admin/sponsorship_levels/index.html.haml_spec.rb index 29ec4f7e..d3abb41e 100644 --- a/spec/views/admin/sponsorship_levels/index.html.haml_spec.rb +++ b/spec/views/admin/sponsorship_levels/index.html.haml_spec.rb @@ -5,6 +5,6 @@ describe 'admin/sponsorship_levels/index' do @sponsorship_level = create(:sponsorship_level) assign :conference, @sponsorship_level.conference render - expect(rendered).to include('Platin') + expect(rendered).to include(@sponsorship_level.title) end end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 18d485eb..46205267 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -1,46 +1,15 @@ require 'spec_helper' describe 'conference/show.html.haml' do + let!(:conference) { create(:full_conference) } + before(:each) do allow(view).to receive(:date_string).and_return('January 17 - 21 2014') - @conference = create(:conference, description: 'Lorem Ipsum') - @program = @conference.program - - @conference.splashpage = create(:splashpage, - include_registrations: true, - include_program: true, - include_sponsors: true, - include_tracks: true, - include_tickets: true, - include_social_media: true, - include_venue: true, - include_lodgings: true, - include_cfp: true) - - @conference.contact.update(sponsor_email: 'example@example.com', - facebook: 'http://facebook.com', - googleplus: 'http://google.com', - instagram: 'http://instagram.com', - twitter: 'http://twitter.com') - - @conference.registration_period = create(:registration_period, - start_date: Date.yesterday, - end_date: Date.tomorrow) - - @conference.program.cfp = create(:cfp, program: @conference.program) - - @conference.sponsorship_levels << create(:sponsorship_level, conference: @conference) - @sponsorship_level = @conference.sponsorship_levels.first - @sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level, - conference: @conference) - - @conference.venue = create(:venue) - @conference.lodgings << create(:lodging) - assign :conference, @conference + assign :conference, conference render end it 'renders banner component' do - expect(rendered).to match(/#{@conference.description}/) + expect(rendered).to match(conference.description) end it 'renders program partial' do @@ -57,32 +26,33 @@ describe 'conference/show.html.haml' do it 'renders sponsors partial' do expect(view).to render_template(partial: 'conference/_sponsors') - expect(rendered).to match(/example@example.com/) - expect(rendered).to match(/www.example.com/) - expect(rendered).to match(/Lorem Ipsum Dolor/) - expect(rendered).to match(/rails.png/) + expect(rendered).to match(conference.contact.email) + expect(rendered).to match(conference.sponsors.first.website_url) + expect(rendered).to match(conference.sponsors.first.description) + expect(rendered).to match(conference.sponsors.first.logo_file_name) end it 'renders social media partial' do expect(view).to render_template('conference/_social_media') - expect(rendered).to match(/facebook.com/) - expect(rendered).to match(/google.com/) - expect(rendered).to match(/instagram.com/) - expect(rendered).to match(/twitter.com/) + expect(rendered).to match(conference.contact.facebook) + expect(rendered).to match(conference.contact.googleplus) + expect(rendered).to match(conference.contact.instagram) + expect(rendered).to match(conference.contact.twitter) end it 'renders venue partial' do expect(view).to render_template(partial: 'conference/_venue') - expect(rendered).to match(/Suse Office/) - expect(rendered).to match(/Maxfeldstrasse 5/) - expect(rendered).to match(/www.opensuse.org/) - expect(rendered).to match(/Lorem Ipsum Dolor/) + expect(rendered).to match(conference.venue.name) + expect(rendered).to match(conference.venue.street) + expect(rendered).to match(conference.venue.website) + expect(rendered).to match(conference.venue.description) end it 'renders lodging partial' do expect(view).to render_template(partial: 'conference/_lodging') - expect(rendered).to match(/Example Hotel/) - expect(rendered).to match(/Lorem Ipsum Dolor/) - expect(rendered).to match(/www.example.com/) + expect(rendered).to match(conference.lodgings.first.name) + expect(rendered).to match(conference.lodgings.first.description) + # FIXME: Lodging without image doesn't show link + # expect(rendered).to match(conference.lodgings.first.website_link) end end