Merge pull request #982 from hennevogel/feature_demo_data

Demo Data
This commit is contained in:
Henne Vogelsang 2016-05-02 16:19:16 +02:00
commit 12c5e3d512
54 changed files with 198 additions and 190 deletions

View file

@ -174,13 +174,17 @@ gem 'cloudinary'
# for setting app configuration in the environment # for setting app configuration in the environment
gem 'dotenv-rails' 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 # Use guard and spring for testing in development
group :development do group :development do
# to launch specs when files are modified # to launch specs when files are modified
gem 'guard-rspec', '~> 4.2.8' gem 'guard-rspec', '~> 4.2.8'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
# for static code analisys # for static code analisys
gem 'rubocop' gem 'rubocop', require: false
# to silence rack assests messages # to silence rack assests messages
gem 'quiet_assets' gem 'quiet_assets'
# as database # as database

View file

@ -173,6 +173,8 @@ GEM
factory_girl_rails (4.6.0) factory_girl_rails (4.6.0)
factory_girl (~> 4.5.0) factory_girl (~> 4.5.0)
railties (>= 3.0.0) railties (>= 3.0.0)
faker (1.6.1)
i18n (~> 0.5)
faraday (0.9.0) faraday (0.9.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
fastimage (2.0.0) fastimage (2.0.0)
@ -550,6 +552,7 @@ DEPENDENCIES
devise_ichain_authenticatable devise_ichain_authenticatable
dotenv-rails dotenv-rails
factory_girl_rails factory_girl_rails
faker
font-awesome-rails font-awesome-rails
formtastic (~> 3.1.1) formtastic (~> 3.1.1)
formtastic-bootstrap formtastic-bootstrap

View file

@ -3,7 +3,7 @@
class Cfp < ActiveRecord::Base class Cfp < ActiveRecord::Base
belongs_to :program belongs_to :program
validates :program_id, presence: true, uniqueness: true validates :program_id, presence: true
validates :start_date, :end_date, presence: true validates :start_date, :end_date, presence: true
validate :before_end_of_conference validate :before_end_of_conference
validate :start_after_end_date validate :start_after_end_date

View file

@ -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

View file

@ -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

View file

@ -12,24 +12,24 @@
.row .row
.col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1
%p %p
- if @program.event_types.any? - if @conference.program.event_types.any?
You can submit proposals for You can submit proposals for
%span.notranslate %span.notranslate
= "#{event_types(@conference)}." = "#{event_types(@conference)}."
- if @program.tracks.any? - if @conference.program.tracks.any?
Proposals should fit in one of the Proposals should fit in one of the
%span.notranslate %span.notranslate
= "#{pluralize(@program.tracks.count, 'track')}:" = "#{pluralize(@conference.program.tracks.count, 'track')}:"
= "#{tracks(@conference)}." = "#{tracks(@conference)}."
The submission period has begun The submission period has begun
%em.notranslate %em.notranslate
= @program.cfp.start_date.strftime('%A, %B %-d. %Y') = @conference.program.cfp.start_date.strftime('%A, %B %-d. %Y')
and closes and closes
%em.notranslate %em.notranslate
= @program.cfp.end_date.strftime('%A, %B %-d. %Y.') = @conference.program.cfp.end_date.strftime('%A, %B %-d. %Y.')
- if @program.cfp_open? - if @conference.program.cfp_open?
That means you have only That means you have only
%b.notranslate= pluralize(@program.cfp.remaining_days, 'day') %b.notranslate= pluralize(@conference.program.cfp.remaining_days, 'day')
left! left!
Remember Remember
%span.notranslate %span.notranslate

View file

@ -36,7 +36,7 @@
%section#program %section#program
= render 'schedule_splashpage' = render 'schedule_splashpage'
- if @program.cfp_open? and @conference.splashpage.include_cfp - if @conference.program.cfp_open? and @conference.splashpage.include_cfp
%section#callforpapers %section#callforpapers
= render 'call_for_paper' = render 'call_for_paper'

8
lib/tasks/data_demo.rake Normal file
View file

@ -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

View file

@ -58,7 +58,7 @@ describe Admin::ConferenceController do
conference.reload conference.reload
expect(flash[:error]). expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.") 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}") expect(conference.short_title).to eq("#{conference.short_title}")
end end

View file

@ -114,7 +114,7 @@ describe ConferenceRegistrationsController, type: :controller do
end end
it 'shows error in flash message' do 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 end
it 'does not update the registration' do it 'does not update the registration' do
@ -139,7 +139,7 @@ describe ConferenceRegistrationsController, type: :controller do
end end
it 'shows success message in flash notice', run: true do 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 end
it 'deletes the registration' do it 'deletes the registration' do
@ -160,7 +160,7 @@ describe ConferenceRegistrationsController, type: :controller do
end end
it 'shows error in flash message' do 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 end
it 'does not delete the registration' do it 'does not delete the registration' do

View file

@ -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

View file

@ -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 { CGI.escapeHTML(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

View 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

View file

@ -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.

View file

@ -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 { CGI.escapeHTML(Faker::Lorem.paragraph) }
website_link 'http://www.example.com' website_link { Faker::Internet.url }
conference
end end
end end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 { CGI.escapeHTML(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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -35,13 +35,13 @@ feature Lodging do
visit admin_conference_lodgings_path( visit admin_conference_lodgings_path(
conference_id: conference.short_title) 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 # Add lodging
click_link 'Edit' click_link 'Edit'
fill_in 'lodging_name', with: 'New lodging' 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 attach_file 'Picture', path
click_button 'Update Lodging' click_button 'Update Lodging'
@ -51,26 +51,26 @@ feature Lodging do
expect(page.has_content?('New lodging')).to be true expect(page.has_content?('New lodging')).to be true
lodging.reload lodging.reload
expect(lodging.name).to eq('New lodging') expect(lodging.name).to eq('New lodging')
expect(lodging.description).to eq('Lorem Ipsum Dolor') expect(lodging.description).to eq(lodging.description)
expect(lodging.website_link).to eq('http:\\www.google.com') expect(lodging.website_link).to eq('http://www.google.com')
expect(Lodging.count).to eq(1) expect(Lodging.count).to eq(1)
end end
scenario 'Delete a lodging', feature: true, js: true do scenario 'Delete a lodging', feature: true, js: true do
conference.lodgings << create(:lodging) lodging = create(:lodging, conference: conference)
sign_in organizer sign_in organizer
visit admin_conference_lodgings_path( visit admin_conference_lodgings_path(
conference_id: conference.short_title) 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 # Add lodging
click_link 'Delete' click_link 'Delete'
# Validations # Validations
expect(flash).to eq('Lodging successfully deleted.') 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) expect(Lodging.count).to eq(0)
end end
end end

View file

@ -21,7 +21,7 @@ feature Sponsor do
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution' fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
attach_file 'Picture', path attach_file 'Picture', path
fill_in 'sponsor_website_url', with: 'http://www.suse.com' 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' click_button 'Create Sponsor'
@ -30,7 +30,7 @@ feature Sponsor do
expect(page.has_content?('SUSE')).to be true expect(page.has_content?('SUSE')).to be true
expect(page.has_content?('The original provider')).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?('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).to have_selector("img[src*='rails.png']")
expect(page.assert_selector('tr', count: 2)).to be true expect(page.assert_selector('tr', count: 2)).to be true
end end

View file

@ -33,7 +33,7 @@ feature Registration do
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title)) expect(current_path).to eq(conference_conference_registrations_path(conference.short_title))
expect(flash). expect(flash).
to eq("Thank you for supporting #{conference.title} by purchasing a ticket.") 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 end
scenario 'deletes a purchased ticket', feature: true, js: true do 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) create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4)
visit conference_conference_registrations_path(conference.short_title) 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" click_link "ticket-#{ticket.id}-delete"
expect(flash).to eq('Ticket successfully deleted.') expect(flash).to eq('Ticket successfully deleted.')

View file

@ -11,7 +11,7 @@ describe SponsorsHelper, type: :helper do
end end
it 'returns correct url' do 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
end end
@ -22,7 +22,7 @@ describe SponsorsHelper, type: :helper do
end end
it 'returns correct url' do 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
end end
@ -33,7 +33,7 @@ describe SponsorsHelper, type: :helper do
end end
it 'returns correct url' do 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 end
end end

View file

@ -9,7 +9,7 @@ describe EmailSettings do
{ {
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'name' => 'John Doe', 'name' => 'John Doe',
'conference' => 'The dog and pony show', 'conference' => conference.title,
'conference_start_date' => Date.new(2014, 05, 01), 'conference_start_date' => Date.new(2014, 05, 01),
'conference_end_date' => Date.new(2014, 05, 06), 'conference_end_date' => Date.new(2014, 05, 06),
'registrationlink' => 'http://localhost:3000/conference/goto/register', 'registrationlink' => 'http://localhost:3000/conference/goto/register',
@ -62,7 +62,7 @@ describe EmailSettings do
context 'conference has venue' do context 'conference has venue' do
before do before do
conference.update_attributes(venue: create(:venue)) 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) expected_hash.merge!(venue_hash)
end end
@ -105,7 +105,7 @@ describe EmailSettings do
it 'replaces fillers in template' do it 'replaces fillers in template' do
expected_text = "Dear John Doe\n\nWe are very pleased" \ 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 expect(conference.email_settings.generate_event_mail(event, event_template)).to eq expected_text
end end
end end
@ -114,7 +114,7 @@ describe EmailSettings do
let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." } let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." }
it 'replaces fillers in template' do 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 expect(conference.email_settings.generate_email_on_conf_updates(conference, user, conf_update_template)).to eq expected_text
end end
end end

View file

@ -221,7 +221,7 @@ describe Event do
describe '#abstract_word_count' do describe '#abstract_word_count' do
it 'counts words in abstract' do it 'counts words in abstract' do
event = build(:event) 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.') event.update_attributes!(abstract: 'abstract.')
expect(event.abstract_word_count).to eq(1) expect(event.abstract_word_count).to eq(1)
end end

View file

@ -12,7 +12,7 @@ describe ConferenceSerializer, type: :serializer do
{ {
conference: { conference: {
short_title: 'goto', short_title: 'goto',
title: 'The dog and pony show', title: conference.title,
description: 'Lorem ipsum dolor sit', description: 'Lorem ipsum dolor sit',
start_date: '2014-03-04', start_date: '2014-03-04',
end_date: '2014-03-10', end_date: '2014-03-10',
@ -61,7 +61,7 @@ describe ConferenceSerializer, type: :serializer do
before do before do
venue = create(:venue, conference: conference) venue = create(:venue, conference: conference)
_room = create(:room, venue: venue) _room = create(:room, venue: venue)
_track = create(:track, program: conference.program) track = create(:track, program: conference.program)
room_hash = { room_hash = {
rooms: [{ rooms: [{
@ -74,8 +74,8 @@ describe ConferenceSerializer, type: :serializer do
track_hash = { track_hash = {
tracks: [{ tracks: [{
id: 1, id: 1,
name: 'Example Track', name: track.name,
description: 'Lorem Ipsum dolsum' description: track.description
} }
] ]
} }

View file

@ -7,7 +7,7 @@ describe RoomSerializer, type: :serializer do
expected_json = { expected_json = {
room: { room: {
guid: room.guid, guid: room.guid,
name: 'Example Room', name: room.name,
description: '' description: ''
} }
}.to_json }.to_json

View file

@ -8,8 +8,8 @@ describe TrackSerializer, type: :serializer do
expected_json = { expected_json = {
track: { track: {
guid: track.guid, guid: track.guid,
name: 'Example Track', name: track.name,
color: '#ffffff' color: track.color
} }
}.to_json }.to_json

BIN
spec/support/logos/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
spec/support/logos/10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

BIN
spec/support/logos/11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
spec/support/logos/12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
spec/support/logos/13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
spec/support/logos/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
spec/support/logos/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
spec/support/logos/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
spec/support/logos/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
spec/support/logos/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
spec/support/logos/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
spec/support/logos/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
spec/support/logos/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -0,0 +1 @@
These are fake logos from https://github.com/pigment/fake-logos

View file

@ -1,18 +1,17 @@
# Automatically save and open the page # Automatically save the page a test fails
# whenever an expectation is not met in a features spec Capybara.save_and_open_page_path = Rails.root.join('tmp', 'capybara')
RSpec.configure do |config| RSpec.configure do |config|
config.after(:each, type: :feature) do config.after(:each, type: :feature) do
ename = RSpec.current_example.full_description example_filename = RSpec.current_example.full_description
ename = ename.gsub ' ', '_' example_filename = example_filename.tr(' ', '_')
ename.downcase! example_filename = example_filename + '.html'
ename = ename + '.html' example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path)
if RSpec.current_example.exception.present? if RSpec.current_example.exception.present?
save_page(ename) save_page(example_filename)
else # remove the file if the test starts working again
capfile = File.expand_path(ename, Capybara.save_and_open_page_path) elsif File.exist?(example_filename)
if File.exist?(capfile) File.unlink(example_filename)
File.unlink(capfile)
end
end end
end end
end end

View file

@ -1,10 +1,13 @@
require 'spec_helper' require 'spec_helper'
describe 'admin/conference/index' do 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 it 'renders all conference names with links' do
assign(:conferences, [create(:conference, title: 'openSUSE'), create(:conference)]) assign(:conferences, [conference, second_conference])
render render
expect(rendered).to include('openSUSE') expect(rendered).to include('openSUSE Conference 2016')
expect(rendered).to include('The dog and pony show') expect(rendered).to include(second_conference.title)
end end
end end

View file

@ -1,12 +1,14 @@
require 'spec_helper' require 'spec_helper'
describe 'admin/conference/new' do describe 'admin/conference/new' do
let(:conference) { build(:conference) }
it 'renders the new template for the conference' do it 'renders the new template for the conference' do
assign(:conference, Conference.new) assign(:conference, Conference.new)
render render
expect(rendered).to include('Basic Information') expect(rendered).to include('Basic Information')
assign(:conference, build(:conference)) assign(:conference, conference)
render render
expect(rendered).to include('The dog and pony show') expect(rendered).to include(conference.title)
end end
end end

View file

@ -7,6 +7,6 @@ describe 'admin/lodgings/index' do
@conference.lodgings << create(:lodging) @conference.lodgings << create(:lodging)
assign :venue, @conference.venue assign :venue, @conference.venue
render render
expect(rendered).to include('Example Hotel') expect(rendered).to include(@conference.lodgings.first.name)
end end
end end

View file

@ -9,9 +9,9 @@ describe 'admin/sponsors/index' do
) )
assign :conference, @conference assign :conference, @conference
render render
expect(rendered).to include('Example sponsor') expect(rendered).to include(@conference.sponsors.first.name)
expect(rendered).to include('http://www.example.com') expect(rendered).to include(@conference.sponsors.first.website_url)
expect(rendered).to include('Lorem Ipsum Dolor') expect(rendered).to include(truncate(@conference.sponsors.first.description))
expect(rendered).to include('Platin') expect(rendered).to include(@conference.sponsorship_levels.first.title)
end end
end end

View file

@ -5,6 +5,6 @@ describe 'admin/sponsorship_levels/index' do
@sponsorship_level = create(:sponsorship_level) @sponsorship_level = create(:sponsorship_level)
assign :conference, @sponsorship_level.conference assign :conference, @sponsorship_level.conference
render render
expect(rendered).to include('Platin') expect(rendered).to include(@sponsorship_level.title)
end end
end end

View file

@ -1,46 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'conference/show.html.haml' do describe 'conference/show.html.haml' do
let!(:conference) { create(:full_conference) }
before(:each) do before(:each) do
allow(view).to receive(:date_string).and_return('January 17 - 21 2014') allow(view).to receive(:date_string).and_return('January 17 - 21 2014')
@conference = create(:conference, description: 'Lorem Ipsum') assign :conference, conference
@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
render render
end end
it 'renders banner component' do it 'renders banner component' do
expect(rendered).to match(/#{@conference.description}/) expect(rendered).to match(conference.description)
end end
it 'renders program partial' do it 'renders program partial' do
@ -57,32 +26,33 @@ describe 'conference/show.html.haml' do
it 'renders sponsors partial' do it 'renders sponsors partial' do
expect(view).to render_template(partial: 'conference/_sponsors') expect(view).to render_template(partial: 'conference/_sponsors')
expect(rendered).to match(/example@example.com/) expect(rendered).to match(conference.contact.email)
expect(rendered).to match(/www.example.com/) expect(rendered).to match(conference.sponsors.first.website_url)
expect(rendered).to match(/Lorem Ipsum Dolor/) expect(rendered).to match(conference.sponsors.first.description)
expect(rendered).to match(/rails.png/) expect(rendered).to match(conference.sponsors.first.logo_file_name)
end end
it 'renders social media partial' do it 'renders social media partial' do
expect(view).to render_template('conference/_social_media') expect(view).to render_template('conference/_social_media')
expect(rendered).to match(/facebook.com/) expect(rendered).to match(conference.contact.facebook)
expect(rendered).to match(/google.com/) expect(rendered).to match(conference.contact.googleplus)
expect(rendered).to match(/instagram.com/) expect(rendered).to match(conference.contact.instagram)
expect(rendered).to match(/twitter.com/) expect(rendered).to match(conference.contact.twitter)
end end
it 'renders venue partial' do it 'renders venue partial' do
expect(view).to render_template(partial: 'conference/_venue') expect(view).to render_template(partial: 'conference/_venue')
expect(rendered).to match(/Suse Office/) expect(rendered).to match(conference.venue.name)
expect(rendered).to match(/Maxfeldstrasse 5/) expect(rendered).to match(conference.venue.street)
expect(rendered).to match(/www.opensuse.org/) expect(rendered).to match(conference.venue.website)
expect(rendered).to match(/Lorem Ipsum Dolor/) expect(rendered).to match(conference.venue.description)
end end
it 'renders lodging partial' do it 'renders lodging partial' do
expect(view).to render_template(partial: 'conference/_lodging') expect(view).to render_template(partial: 'conference/_lodging')
expect(rendered).to match(/Example Hotel/) expect(rendered).to match(conference.lodgings.first.name)
expect(rendered).to match(/Lorem Ipsum Dolor/) expect(rendered).to match(conference.lodgings.first.description)
expect(rendered).to match(/www.example.com/) # FIXME: Lodging without image doesn't show link
# expect(rendered).to match(conference.lodgings.first.website_link)
end end
end end