Extracted Splashpage from Conference

#418
This commit is contained in:
Chrisbr 2014-08-30 12:08:24 +02:00
parent 7793497862
commit fedb0753bf
42 changed files with 578 additions and 236 deletions

View file

@ -21,21 +21,21 @@ describe Admin::RegistrationPeriodsController do
context 'valid attributes' do
it 'locates the requested audience object' do
it 'locates the requested registration period object' do
patch :update, conference_id: conference.short_title, conference: attributes_for(:registration_period)
expect(assigns(:registration_period)).to eq(conference.registration_period)
end
it 'changes audience attributes' do
it 'changes registration period attributes' do
the_date = 10.days.from_now.to_date
patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period,
description: 'Test')
attributes_for(:registration_period, start_date: the_date)
conference.reload
expect(conference.registration_period.description).to eq('Test')
expect(conference.registration_period.start_date.to_s).to eq(the_date.to_s)
end
it 'redirects to the updated conference' do
it 'redirects to the updated registration period' do
patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period)
conference.reload
@ -83,7 +83,7 @@ describe Admin::RegistrationPeriodsController do
end
context 'with invalid attributes' do
it 'does not save the conference to the database' do
it 'does not save the registration period to the database' do
expected = expect do
post :create,
conference_id: conference.short_title,
@ -106,7 +106,7 @@ describe Admin::RegistrationPeriodsController do
end
describe 'GET #edit' do
it 'assigns the requested conference to conference' do
it 'assigns the requested registration period to @registration_period' do
get :edit, conference_id: conference.short_title
expect(assigns(:registration_period)).to eq conference.registration_period
end
@ -118,7 +118,7 @@ describe Admin::RegistrationPeriodsController do
end
describe 'GET #show' do
it 'assigns the requested registration period to registration period' do
it 'assigns the requested registration period to @registration_period' do
get :show, conference_id: conference.short_title
expect(assigns(:registration_period)).to eq conference.registration_period
end
@ -130,7 +130,7 @@ describe Admin::RegistrationPeriodsController do
end
describe 'GET #new' do
it 'assigns a new conference to conference' do
it 'assigns a new registration period to @registration_period' do
get :new, conference_id: conference.short_title
expect(assigns(:registration_period)).to be_a_new(RegistrationPeriod)
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe ConferenceController do
let(:conference) { create(:conference, make_conference_public: true) }
let(:conference) { create(:conference, splashpage: create(:splashpage, public: true)) }
describe 'GET #show' do
context 'conference made public' do
@ -15,19 +15,7 @@ describe ConferenceController do
expect(response).to render_template :show
end
end
context 'conference is not public' do
before(:each) { conference.update_attribute(:make_conference_public, false) }
it 'redirects to root path' do
get :show, id: conference.short_title
expect(response).to redirect_to root_path
end
it 'renders flash saying conference not ready' do
get :show, id: conference.short_title
expect(flash[:alert]).to eq('You are not authorized to access this page.')
end
end
context 'gallery photos for splash' do
it 'return conference photos' do
xhr :get, :gallery_photos, id: conference.short_title

View file

@ -7,7 +7,6 @@ FactoryGirl.define do
timezone 'Amsterdam'
start_date { Date.today }
end_date { 6.days.from_now }
make_conference_public true
venue
end
end

View file

@ -4,6 +4,5 @@ FactoryGirl.define do
factory :registration_period do
start_date { 3.days.from_now }
end_date { 5.days.from_now }
description 'Lorem ipsum dolorem ...'
end
end

View file

@ -0,0 +1,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :splashpage do
public true
end
end

View file

@ -14,7 +14,6 @@ feature RegistrationPeriod do
conference_id: conference.short_title)
click_link 'New Registration Period'
fill_in 'registration_period_description', with: 'The description'
click_button 'Save Registration Period'
expect(flash).
@ -37,7 +36,6 @@ feature RegistrationPeriod do
registration_period.reload
expect(registration_period.start_date).to eq(Date.today)
expect(registration_period.end_date).to eq(Date.today + 7)
expect(registration_period.description).to eq('The description')
end
end

View file

@ -0,0 +1,94 @@
require 'spec_helper'
feature Splashpage do
# It is necessary to use bang version of let to build roles before user
let!(:conference) { create(:conference) }
let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
let!(:participant) { create(:user, biography: '') }
scenario 'create a valid splashpage', js: true do
sign_in organizer
visit admin_conference_splashpage_path(conference.short_title)
click_link 'Create Splashpage'
fill_in 'splashpage_banner_description', with: 'banner description'
fill_in 'splashpage_ticket_description', with: 'ticket description'
fill_in 'splashpage_sponsor_description', with: 'sponsor description'
fill_in 'splashpage_registration_description', with: 'registration description'
fill_in 'splashpage_lodging_description', with: 'lodging description'
click_button 'Save Splashpage'
expect(flash).to eq('Splashpage successfully created.')
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
splashpage = Splashpage.find_by(conference_id: conference.id)
splashpage.reload
expect(splashpage.banner_description).to eq('banner description')
expect(splashpage.ticket_description).to eq('ticket description')
expect(splashpage.sponsor_description).to eq('sponsor description')
expect(splashpage.registration_description).to eq('registration description')
expect(splashpage.lodging_description).to eq('lodging description')
end
context 'splashpage already created' do
# before(:each) do
# @splashpage = create(:splashpage)
# conference.splashpage = @splashpage
# end
#
let!(:splashpage) { create(:splashpage, conference: conference, public: false)}
scenario 'update a valid splashpage', js: true do
sign_in organizer
visit admin_conference_splashpage_path(conference.short_title)
click_link 'Edit'
fill_in 'splashpage_banner_description', with: 'banner description'
fill_in 'splashpage_ticket_description', with: 'ticket description'
fill_in 'splashpage_sponsor_description', with: 'sponsor description'
fill_in 'splashpage_registration_description', with: 'registration description'
fill_in 'splashpage_lodging_description', with: 'lodging description'
click_button 'Save Splashpage'
expect(flash).to eq('Splashpage successfully updated.')
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
splashpage.reload
expect(splashpage.banner_description).to eq('banner description')
expect(splashpage.ticket_description).to eq('ticket description')
expect(splashpage.sponsor_description).to eq('sponsor description')
expect(splashpage.registration_description).to eq('registration description')
expect(splashpage.lodging_description).to eq('lodging description')
end
scenario 'delete the splashpage', js: true do
sign_in organizer
visit admin_conference_splashpage_path(conference.short_title)
click_link 'Delete'
expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title))
expect(flash).to eq('Splashpage was successfully destroyed.')
expect(Splashpage.count).to eq(0)
end
scenario 'splashpage is accessible for organizers if it is not public' do
sign_in organizer
visit conference_path(conference.short_title)
expect(current_path).to eq(conference_path(conference.short_title))
end
scenario 'splashpage is not accessible for participants if it is not public' do
sign_in participant
visit conference_path(conference.short_title)
expect(flash).to eq('You are not authorized to access this page.')
expect(current_path).to eq(root_path)
end
end
end

View file

@ -6,8 +6,8 @@ describe 'User' do
subject(:ability){ Ability.new(user) }
let!(:first_user) { create(:user) } # automatically becomes admin
let(:user){ nil }
let(:conference_not_public) { create(:conference, make_conference_public: false) }
let(:conference_public) { create(:conference, make_conference_public: true)}
let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) }
let(:conference_public) { create(:conference, splashpage: create(:splashpage, public: true)) }
let(:event_confirmed) { create(:event, state: 'confirmed') }
let(:someevent) { create(:event) }
@ -113,8 +113,8 @@ describe 'User' do
let!(:conference2) { create(:conference) } # user is cfp
let!(:conference3) { create(:conference) } # user is info_desk
let!(:conference4) { create(:conference) } # user is volunteer coordinator
let!(:conference5) { create(:conference, make_conference_public: true) } # user has no role
let!(:conference6) { create(:conference, make_conference_public: false) } # user has no role
let!(:conference5) { create(:conference, splashpage: create(:splashpage, public: true)) } # user has no role
let!(:conference6) { create(:conference, splashpage: create(:splashpage, public: false)) } # user has no role
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
let(:role_info_desk) { create(:role, name: 'info_desk', resource: conference3) }

View file

@ -952,7 +952,7 @@ describe Conference do
@result['tracks'] = true
@result['event_types'] = true
@result['difficulty_levels'] = true
@result['make_conference_public'] = true
@result['splashpage'] = true
# Setup negative result hash
@result_false = Hash.new
@ -970,7 +970,7 @@ describe Conference do
subject.tracks = []
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
expect(subject.get_status).to eq(@result_false)
end
@ -984,7 +984,7 @@ describe Conference do
subject.tracks = []
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['registration'] = true
@result_false['process'] = 13.to_s
@ -1001,7 +1001,7 @@ describe Conference do
subject.tracks = []
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['cfp'] = true
@result_false['registration'] = true
@ -1020,7 +1020,7 @@ describe Conference do
subject.tracks = []
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['cfp'] = true
@result_false['registration'] = true
@ -1040,7 +1040,7 @@ describe Conference do
subject.tracks = []
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['cfp'] = true
@result_false['registration'] = true
@ -1061,7 +1061,7 @@ describe Conference do
subject.venue = create(:venue)
subject.event_types = []
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['cfp'] = true
@result_false['registration'] = true
@ -1084,7 +1084,7 @@ describe Conference do
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.difficulty_levels = []
subject.make_conference_public = false
subject.splashpage = create(:splashpage, public: false)
@result_false['cfp'] = true
@result_false['registration'] = true
@ -1108,7 +1108,7 @@ describe Conference do
subject.venue = create(:venue)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.make_conference_public = true
subject.splashpage = create(:splashpage, public: true)
expect(subject.get_status).to eq(@result)
end

View file

@ -3,23 +3,26 @@ describe 'conference/show.html.haml' do
before(:each) do
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
@conference = create(:conference,
description: 'Lorem Ipsum',
sponsor_description: 'Lorem Ipsum Dolor',
sponsor_email: 'example@example.com',
include_registrations_in_splash: true,
include_program_in_splash: true,
include_sponsors_in_splash: true,
include_tracks_in_splash: true,
include_tickets_in_splash: true,
include_banner_in_splash: true)
sponsor_email: 'example@example.com')
@conference.splashpage = create(:splashpage,
banner_description: 'Lorem Ipsum',
sponsor_description: 'Lorem Ipsum Dolor',
registration_description: 'Lorem Ipsum Dolor',
include_registrations: true,
include_program: true,
include_sponsors: true,
include_tracks: true,
include_tickets: true,
include_banner: true,
include_social_media: true,
include_venue: true,
include_lodgings: true)
@conference.contact.update(facebook: 'http://www.fbexample.com',
googleplus: 'http://www.google-example.com',
instagram: 'http://instagram.com',
twitter: 'http://twitter.com',
public: true
)
twitter: 'http://twitter.com')
@conference.registration_period = create(:registration_period,
description: 'Lorem Ipsum Dolor',
start_date: Date.today,
end_date: Date.tomorrow)
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
@ -30,15 +33,14 @@ describe 'conference/show.html.haml' do
@sponsorship_level = @conference.sponsorship_levels.first
@sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level,
conference: @conference)
@conference.venue = create(:venue, include_venue_in_splash: true,
include_lodgings_in_splash: true)
@conference.venue = create(:venue)
@conference.venue.lodgings << create(:lodging, venue: @conference.venue)
assign :conference, @conference
render
end
it 'renders banner component' do
expect(view.content_for(:splash)).to include("#{@conference.description}")
expect(view.content_for(:splash)).to include("#{@conference.splashpage.banner_description}")
expect(view.content_for(:splash)).to include("#{@conference.short_title}")
end
@ -47,7 +49,7 @@ describe 'conference/show.html.haml' do
end
it 'renders registration partial' do
expect(view.content_for(:splash)).to include("#{@conference.registration_period.description}")
expect(view.content_for(:splash)).to include("#{@conference.splashpage.registration_description}")
expect(view).to render_template(partial: 'conference/_registration')
end