Merge pull request #985 from hennevogel/feature_factories

Some fixes for review apps
This commit is contained in:
Christian Bruckmayer 2016-05-12 12:49:47 +02:00
commit 3d2e1f3219
16 changed files with 40 additions and 35 deletions

View file

@ -7,7 +7,14 @@ class PictureUploader < CarrierWave::Uploader::Base
# use cloudinary if it's configured
if Cloudinary.config.cloud_name
# use https by default
Cloudinary.config.secure = true
include Cloudinary::CarrierWave
def public_id
model.try(:photo_file_name) || model.try(:logo_file_name)
end
end
def paperclip_path

View file

@ -2,7 +2,9 @@ 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')
conference = create(:full_conference, title: 'Open Source Event Manager Demo', short_title: 'osemdemo' ,description: "This is a [Open Source Event Manager](http://osem.io/) demo instance. You can log in as **admin** with the password **password123** or just you just [sign up](/accounts/sign_up) with your own user. We hope you enjoy checking out all the functionality, if you have questions don't hesitate to [contact us](http://osem.io/#contact)!\r\n\r\n## Data will be destroyed every thirty minutes or whenever someone updates the [OSEM source code on github](https://github.com/openSUSE/osem/commits/master).")
conference.contact.update_attributes(email: 'osemdemo@osem.io', sponsor_email: 'osemdemo@osem.io')
create(:admin, email: 'admin@osem.io', username: 'admin', password: 'password123', password_confirmation: 'password123')
end
end

View file

@ -8,7 +8,7 @@ FactoryGirl.define do
start_date { Date.today }
end_date { 6.days.from_now }
registration_limit 0
description { CGI.escapeHTML(Faker::Hipster.paragraph) }
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)')
@ -46,10 +46,10 @@ FactoryGirl.define do
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
File.open('spec/support/logos/OSEM.jpg') do |file|
conference.picture = file
end
conference.save!
end
end
end

View file

@ -30,6 +30,5 @@ FactoryGirl.define do
event.comment_threads << build(:comment, commentable: event)
end
end
end
end

View file

@ -3,7 +3,7 @@
FactoryGirl.define do
factory :lodging do
name { "#{Faker::App.name} Hotel" }
description { CGI.escapeHTML(Faker::Lorem.paragraph) }
description { Faker::Lorem.paragraph }
website_link { Faker::Internet.url }
end
end

View file

@ -4,16 +4,15 @@ FactoryGirl.define do
factory :sponsor do
name { Faker::Company.name }
website_url { Faker::Internet.url }
description { CGI.escapeHTML(Faker::Lorem.paragraph) }
description { Faker::Lorem.paragraph }
sponsorship_level
after(:create) do |sponsor|
logo = "#{1 + rand(13)}.png"
uploader = PictureUploader.new(sponsor, :picture)
File.open("spec/support/logos/#{logo}") { |f| uploader.store!(f) }
sponsor.logo_file_name = logo.to_s
sponsor.save
File.open("spec/support/logos/#{1 + rand(13)}.png") do |file|
sponsor.picture = file
end
sponsor.save!
end
end
end

View file

@ -2,7 +2,7 @@
FactoryGirl.define do
factory :sponsorship_level do
title { Faker::Hipster.word }
title { Faker::Lorem.word }
conference
end

View file

@ -8,7 +8,5 @@ FactoryGirl.define do
country { Faker::Address.country_code }
website { Faker::Internet.url }
description { Faker::Lorem.sentence }
conference
end
end

View file

@ -15,7 +15,7 @@ feature Lodging do
click_link 'Add 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
click_button 'Create Lodging'
@ -35,7 +35,7 @@ feature Lodging do
visit admin_conference_lodgings_path(
conference_id: conference.short_title)
expect(page.has_content?(lodging.name)).to be true
expect(page.has_content?(CGI.escapeHTML(lodging.name))).to be true
# Add lodging
click_link 'Edit'
@ -51,7 +51,7 @@ 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(lodging.description)
expect(lodging.description).to eq(CGI.escapeHTML(lodging.description))
expect(lodging.website_link).to eq('http://www.google.com')
expect(Lodging.count).to eq(1)
end
@ -70,7 +70,7 @@ feature Lodging do
# Validations
expect(flash).to eq('Lodging successfully deleted.')
expect(page.has_content?(lodging.name)).to be false
expect(page.has_content?(CGI.escapeHTML(lodging.name))).to be false
expect(Lodging.count).to eq(0)
end
end

BIN
spec/support/logos/OSEM.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -8,6 +8,6 @@ describe 'admin/conference/index' do
assign(:conferences, [conference, second_conference])
render
expect(rendered).to include('openSUSE Conference 2016')
expect(rendered).to include(second_conference.title)
expect(rendered).to include(CGI.escapeHTML(second_conference.title))
end
end

View file

@ -9,6 +9,6 @@ describe 'admin/conference/new' do
expect(rendered).to include('Basic Information')
assign(:conference, conference)
render
expect(rendered).to include(conference.title)
expect(rendered).to include(CGI.escapeHTML(conference.title))
end
end

View file

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

View file

@ -9,9 +9,9 @@ describe 'admin/sponsors/index' do
)
assign :conference, @conference
render
expect(rendered).to include(@conference.sponsors.first.name)
expect(rendered).to include(CGI.escapeHTML(@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)
expect(rendered).to include(truncate(CGI.escapeHTML(@conference.sponsors.first.description)))
expect(rendered).to include(CGI.escapeHTML(@conference.sponsorship_levels.first.title))
end
end

View file

@ -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(@sponsorship_level.title)
expect(rendered).to include(CGI.escapeHTML(@sponsorship_level.title))
end
end

View file

@ -9,7 +9,7 @@ describe 'conference/show.html.haml' do
end
it 'renders banner component' do
expect(rendered).to match(conference.description)
expect(rendered).to match(CGI.escapeHTML(conference.description))
end
it 'renders program partial' do
@ -28,7 +28,7 @@ describe 'conference/show.html.haml' do
expect(view).to render_template(partial: 'conference/_sponsors')
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(CGI.escapeHTML(conference.sponsors.first.description))
expect(rendered).to match(conference.sponsors.first.logo_file_name)
end
@ -42,16 +42,16 @@ describe 'conference/show.html.haml' do
it 'renders venue partial' do
expect(view).to render_template(partial: 'conference/_venue')
expect(rendered).to match(conference.venue.name)
expect(rendered).to match(CGI.escapeHTML(conference.venue.name))
expect(rendered).to match(conference.venue.street)
expect(rendered).to match(conference.venue.website)
expect(rendered).to match(conference.venue.description)
expect(rendered).to match(CGI.escapeHTML(conference.venue.description))
end
it 'renders lodging partial' do
expect(view).to render_template(partial: 'conference/_lodging')
expect(rendered).to match(conference.lodgings.first.name)
expect(rendered).to match(conference.lodgings.first.description)
expect(rendered).to match(CGI.escapeHTML(conference.lodgings.first.name))
expect(rendered).to match(CGI.escapeHTML(conference.lodgings.first.description))
# FIXME: Lodging without image doesn't show link
# expect(rendered).to match(conference.lodgings.first.website_link)
end