Implement consistent admin interface

* Consistent route/model/controller/view layout
* Get rid of unused photos, speakers, dietchoices, social_events controllers
* Drop unused :public from Rooms and :description from CallForPapers
This commit is contained in:
Henne Vogelsang 2014-11-25 10:47:18 +01:00
parent f6a87331be
commit 28063129c7
133 changed files with 1461 additions and 1461 deletions

View file

@ -165,9 +165,9 @@ describe Admin::ConferenceController do
it 'assigns cfp_max an array with maximum weeks' do
conference
date = Date.new(2014, 05, 26)
conference.call_for_papers = create(:call_for_papers,
start_date: date,
end_date: date + 14)
conference.call_for_paper = create(:call_for_paper,
start_date: date,
end_date: date + 14)
get :index
expect(assigns(:cfp_weeks)).to match_array([1, 2, 3])
end

View file

@ -22,18 +22,6 @@ describe ConferenceController do
expect(response).to render_template :show
end
end
context 'gallery photos for splash' do
it 'return conference photos' do
xhr :get, :gallery_photos, id: conference.short_title
expect(assigns(:photos)).to eq conference.photos
end
it 'renders photos template' do
xhr :get, :gallery_photos, id: conference.short_title
expect(response).to render_template :photos
end
end
end
describe 'OPTIONS #index' do

View file

@ -1,10 +1,8 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :call_for_papers do
factory :call_for_paper do
start_date { 1.day.ago }
end_date { 7.days.from_now }
description 'We call for papers'
conference
end
end

View file

@ -1,14 +0,0 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :photo do
picture { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'rails.png'), 'image/png') }
picture_file_name 'rails.png'
picture_content_type 'image/png'
picture_file_size '1024'
picture_updated_at { DateTime.now }
description 'Lorem Ipsum Dolor'
conference
end
end

View file

@ -23,7 +23,6 @@ feature 'Has correct abilities' do
expect(page).to have_link('Basics', href: "/admin/conference/#{conference1.short_title}/edit")
expect(page).to have_link('Contact', href: "/admin/conference/#{conference1.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference1.short_title}/commercials")
expect(page).to have_link('Photos', href: "/admin/conference/#{conference1.short_title}/photos")
expect(page).to have_link('Events', href: "/admin/conference/#{conference1.short_title}/events")
expect(page).to have_link('Registrations', href: "/admin/conference/#{conference1.short_title}/registrations")
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference1.short_title}/schedule")
@ -36,7 +35,7 @@ feature 'Has correct abilities' do
expect(page).to have_link('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors")
expect(page).to have_link('Tickets', href: "/admin/conference/#{conference1.short_title}/tickets")
expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference1.short_title}/emails")
expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference1.short_title}/callforpapers")
expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference1.short_title}/call_for_paper")
expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/tracks")
expect(page).to have_link('Event Types', href: "/admin/conference/#{conference1.short_title}/event_types")
expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference1.short_title}/difficulty_levels")
@ -76,8 +75,8 @@ feature 'Has correct abilities' do
visit admin_conference_emails_path(conference1.short_title)
expect(current_path).to eq(admin_conference_emails_path(conference1.short_title))
visit admin_conference_callforpapers_path(conference1.short_title)
expect(current_path).to eq(admin_conference_callforpapers_path(conference1.short_title))
visit new_admin_conference_call_for_paper_path(conference1.short_title)
expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference1.short_title))
visit admin_conference_questions_path(conference1.short_title)
expect(current_path).to eq(admin_conference_questions_path(conference1.short_title))
@ -94,7 +93,6 @@ feature 'Has correct abilities' do
expect(page).to have_link('Basics', href: "/admin/conference/#{conference2.short_title}/edit")
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference2.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference2.short_title}/commercials")
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference2.short_title}/photos")
expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/events")
expect(page).to_not have_link('Registrations', href: "/admin/conference/#{conference2.short_title}/registrations")
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference2.short_title}/schedule")
@ -107,7 +105,7 @@ feature 'Has correct abilities' do
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference2.short_title}/sponsors")
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference2.short_title}/supporter_levels")
expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference2.short_title}/emails")
expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference2.short_title}/callforpapers")
expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference2.short_title}/call_for_paper")
expect(page).to have_link('Tracks', href: "/admin/conference/#{conference2.short_title}/tracks")
expect(page).to have_link('Event Types', href: "/admin/conference/#{conference2.short_title}/event_types")
expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference2.short_title}/difficulty_levels")
@ -147,8 +145,8 @@ feature 'Has correct abilities' do
visit admin_conference_emails_path(conference2.short_title)
expect(current_path).to eq(admin_conference_emails_path(conference2.short_title))
visit admin_conference_callforpapers_path(conference2.short_title)
expect(current_path).to eq(admin_conference_callforpapers_path(conference2.short_title))
visit new_admin_conference_call_for_paper_path(conference2.short_title)
expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference2.short_title))
visit admin_conference_questions_path(conference2.short_title)
expect(current_path).to eq(root_path)
@ -165,7 +163,6 @@ feature 'Has correct abilities' do
expect(page).to have_link('Basics', href: "/admin/conference/#{conference3.short_title}/edit")
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference3.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference3.short_title}/commercials")
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference3.short_title}/photos")
expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/events")
expect(page).to have_link('Registrations', href: "/admin/conference/#{conference3.short_title}/registrations")
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference3.short_title}/schedule")
@ -178,7 +175,7 @@ feature 'Has correct abilities' do
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference3.short_title}/sponsors")
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference3.short_title}/supporter_levels")
expect(page).to_not have_link('E-Mails', href: "/admin/conference/#{conference3.short_title}/emails")
expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/callforpapers")
expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/call_for_paper")
expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference3.short_title}/tracks")
expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference3.short_title}/event_types")
expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference3.short_title}/difficulty_levels")
@ -218,7 +215,7 @@ feature 'Has correct abilities' do
visit admin_conference_emails_path(conference3.short_title)
expect(current_path).to eq(root_path)
visit admin_conference_callforpapers_path(conference3.short_title)
visit new_admin_conference_call_for_paper_path(conference3.short_title)
expect(current_path).to eq(root_path)
visit admin_conference_questions_path(conference3.short_title)
@ -237,7 +234,6 @@ feature 'Has correct abilities' do
expect(page).to have_link('Basics', href: "/admin/conference/#{conference4.short_title}/edit")
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference4.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference4.short_title}/commercials")
expect(page).to_not have_link('Photos', href: "/admin/conference/#{conference4.short_title}/photos")
expect(page).to_not have_link('Events', href: "/admin/conference/#{conference4.short_title}/events")
expect(page).to_not have_link('Registrations', href: "/admin/conference/#{conference4.short_title}/registrations")
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference4.short_title}/schedule")
@ -250,7 +246,7 @@ feature 'Has correct abilities' do
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference4.short_title}/sponsors")
expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference4.short_title}/supporter_levels")
expect(page).to_not have_link('E-Mails', href: "/admin/conference/#{conference4.short_title}/emails")
expect(page).to_not have_link('Call for Papers', href: "/admin/conference/#{conference4.short_title}/callforpapers")
expect(page).to_not have_link('Call for Papers', href: "/admin/conference/#{conference4.short_title}/call_for_paper")
expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference4.short_title}/tracks")
expect(page).to_not have_link('Event Types', href: "/admin/conference/#{conference4.short_title}/event_types")
expect(page).to_not have_link('Difficulty Levels', href: "/admin/conference/#{conference4.short_title}/difficulty_levels")
@ -290,7 +286,7 @@ feature 'Has correct abilities' do
visit admin_conference_emails_path(conference4.short_title)
expect(current_path).to eq(root_path)
visit admin_conference_callforpapers_path(conference4.short_title)
visit new_admin_conference_call_for_paper_path(conference4.short_title)
expect(current_path).to eq(root_path)
visit admin_conference_questions_path(conference4.short_title)

View file

@ -33,10 +33,10 @@ feature Campaign do
expect(flash).
to eq('Campaign successfully created.')
expect(find('#name_0').text).to eq('Test Campaign')
expect(find('#visits_0').text).to eq('0')
expect(find('#registrations_0').text).to eq('0')
expect(find('#submissions_0').text).to eq('0')
expect(find('#name_1').text).to eq('Test Campaign')
expect(find('#visits_1').text).to eq('0')
expect(find('#registrations_1').text).to eq('0')
expect(find('#submissions_1').text).to eq('0')
expect(Campaign.count).to eq(expected_count)

View file

@ -8,13 +8,13 @@ feature Conference do
shared_examples 'add and update cfp' do
scenario 'adds a new cfp', feature: true, js: true do
expected_count = CallForPapers.count + 1
expected_count = CallForPaper.count + 1
sign_in organizer
visit admin_conference_callforpapers_path(conference.short_title)
visit new_admin_conference_call_for_paper_path(conference.short_title)
click_button 'Create Call for papers'
click_button 'Create Call for paper'
expect(flash).
to eq('Creating the call for papers failed. ' +
@ -26,36 +26,32 @@ feature Conference do
page.execute_script(
"$('#conference-end-datepicker').val('#{(today + 7).strftime('%d/%m/%Y')}')")
fill_in 'call_for_papers_description', with: 'Cfp description'
fill_in 'call_for_papers_rating', with: '4'
fill_in 'call_for_paper_rating', with: '4'
click_button 'Create Call for papers'
click_button 'Create Call for paper'
# Validations
expect(flash).
to eq('Call for Papers was successfully created.')
expect(find('#conference-start-datepicker').value).
to eq(today.strftime('%Y-%m-%d'))
expect(find('#conference-end-datepicker').value).
to eq((today + 7).strftime('%Y-%m-%d'))
expect(find('#call_for_papers_description').text).
to eq('Cfp description')
expect(find('#call_for_papers_rating').value).to eq('4')
to eq('Call for papers successfully created.')
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
expect(find('#end_date').text).to eq((today + 7).strftime('%A, %B %-d. %Y'))
expect(find('#rating').text).to eq('4')
expect(CallForPapers.count).to eq(expected_count)
expect(CallForPaper.count).to eq(expected_count)
end
scenario 'update cfp', feature: true, js: true do
conference.call_for_papers = create(:call_for_papers)
expected_count = CallForPapers.count
conference.call_for_paper = create(:call_for_paper)
expected_count = CallForPaper.count
sign_in organizer
visit admin_conference_callforpapers_path(conference.short_title)
visit admin_conference_call_for_paper_path(conference.short_title)
click_link 'Edit'
# Validate update with empty start date will not saved
page.execute_script(
"$('#conference-start-datepicker').val('')")
click_button 'Update Call for papers'
click_button 'Update Call for paper'
expect(flash).
to eq('Updating call for papers failed. ' +
"Start date can't be blank.")
@ -67,21 +63,16 @@ feature Conference do
page.execute_script(
"$('#conference-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')")
fill_in 'call_for_papers_description', with: 'Updated description'
fill_in 'call_for_papers_rating', with: '0'
click_button 'Update Call for papers'
fill_in 'call_for_paper_rating', with: '0'
click_button 'Update Call for paper'
# Validations
expect(flash).
to eq('Call for Papers was successfully updated.')
expect(find('#conference-start-datepicker').value).
to eq(today.strftime('%Y-%m-%d'))
expect(find('#conference-end-datepicker').value).
to eq((today + 14).strftime('%Y-%m-%d'))
expect(find('#call_for_papers_description').text).
to eq('Updated description')
expect(find('#call_for_papers_rating').value).to eq('0')
expect(CallForPapers.count).to eq(expected_count)
to eq('Call for papers successfully updated.')
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
expect(find('#end_date').text).to eq((today + 14).strftime('%A, %B %-d. %Y'))
expect(find('#rating').text).to eq('0')
expect(CallForPaper.count).to eq(expected_count)
end
end

View file

@ -14,7 +14,7 @@ feature Commercial do
sign_in organizer
visit admin_conference_commercials_path(conference.short_title)
click_link 'New Commercial'
click_link 'Add Commercial'
# Create without an commercial id
select('SlideShare', from: 'commercial_commercial_type')

View file

@ -39,9 +39,8 @@ feature Conference do
expected_count = Conference.count
sign_in organizer
visit edit_admin_conference_path(conference.short_title)
click_link 'Edit'
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: ''
@ -49,9 +48,9 @@ feature Conference do
expect(flash).
to eq("Updating conference failed. Short title can't be blank.")
click_link 'Edit'
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon'
day = Date.today + 10
page.
execute_script("$('#conference-start-datepicker').val('" +

View file

@ -14,7 +14,7 @@ feature Contact do
sign_in organizer
visit edit_admin_conference_contact_path(conference.short_title)
click_link 'Edit'
fill_in 'contact_email', with: 'example@example.com'
fill_in 'contact_sponsor_email', with: 'sponsor@example.com'
fill_in 'contact_social_tag', with: 'example'
@ -24,9 +24,9 @@ feature Contact do
fill_in 'contact_googleplus', with: 'http:\\www.google.com'
click_button 'Update Contact'
expect(flash).
to eq('Contact details were successfully updated.')
contact.reload
expect(contact.email).to eq('example@example.com')
expect(contact.sponsor_email).to eq('sponsor@example.com')

View file

@ -6,47 +6,47 @@ feature DifficultyLevel do
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'difficulty levels' do
scenario 'adds and updates difficulty level', feature: true, js: true do
scenario 'adds difficulty level', feature: true, js: true do
sign_in organizer
visit admin_conference_difficulty_levels_path(
conference_id: conference.short_title)
# Add difficulty level
click_link 'Add difficulty_level'
expect(page.all('div.nested-fields').count == 1).to be true
click_link 'Add Difficulty Level'
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example difficulty level')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
set('Example difficulty level description')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) input').
set('#ff0000')
fill_in 'difficulty_level_title', with: 'Hard'
fill_in 'difficulty_level_description', with: 'Life is the hardest'
page.find('#difficulty_level_color').set('#ff0000')
click_button 'Update Conference'
click_button 'Create Difficulty level'
# Validations
expect(flash).to eq('Difficulty Levels were successfully updated.')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
value).to eq('Example difficulty level')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
value).to eq('Example difficulty level description')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) input').
value).to eq('#ff0000')
expect(flash).to eq('Difficulty level successfully created.')
within('table#difficulty_levels') do
expect(page.has_content?('Hard')).to be true
expect(page.has_content?('Life is the hardest')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
end
scenario 'updates difficulty level', feature: true, js: true do
conference.difficulty_levels << create(:difficulty_level)
sign_in organizer
visit admin_conference_difficulty_levels_path(
conference_id: conference.short_title)
# Remove difficulty level
click_link 'Remove difficulty_level'
expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Conference'
expect(flash).to eq('Difficulty Levels were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
click_link 'Delete'
# Validations
expect(flash).to eq('Difficulty level successfully deleted.')
within('table#difficulty_levels') do
expect(page.assert_selector('tr', count: 1)).to be true
end
end
end
describe 'organizer' do

View file

@ -12,45 +12,40 @@ feature EventType do
visit admin_conference_event_types_path(
conference_id: conference.short_title)
expect(page.all('div.nested-fields').count == 2).to be true
within('table#event_types') do
expect(page.assert_selector('tr', count: 3)).to be true
end
# Add event type
click_link 'Add event_type'
expect(page.all('div.nested-fields').count == 3).to be true
click_link 'Add Event Type'
page.
find('div.nested-fields:nth-of-type(3) div:nth-of-type(1) input').
set('Example event type')
page.
find('div.nested-fields:nth-of-type(3) div:nth-of-type(2) input').
set('60')
page.
find('div.nested-fields:nth-of-type(3) div:nth-of-type(3) input').
set('0')
page.
find('div.nested-fields:nth-of-type(3) div:nth-of-type(4) input').
set('300')
fill_in 'event_type_title', with: 'Party'
fill_in 'event_type_length', with: '240'
fill_in 'event_type_minimum_abstract_length', with: '0'
fill_in 'event_type_maximum_abstract_length', with: '13042'
page.find('#event_type_color').set('#e4e4e4')
click_button 'Update Conference'
click_button 'Create Event type'
# Validations
expect(flash).to eq('Event types were successfully updated.')
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(1) input').
value).to eq('Example event type')
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(2) input').
value).to eq('60')
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(3) input').
value).to eq('0')
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(4) input').
value).to eq('300')
expect(flash).to eq('Event type successfully created.')
within('table#event_types') do
expect(page.has_content?('Party')).to be true
expect(page.has_content?('13042')).to be true
expect(page.has_content?('#e4e4e4')).to be true
expect(page.assert_selector('tr', count: 4)).to be true
end
# Remove event type
within('div.nested-fields:nth-of-type(3)') do
click_link 'Remove event_type'
within('tr', text: 'Party') do
click_link 'Delete'
end
expect(flash).to eq('Event type successfully deleted.')
within('table#event_types') do
expect(page.assert_selector('tr', count: 3)).to be true
expect(page.has_content?('Party')).to be false
end
expect(page.all('div.nested-fields').count == 2).to be true
click_button 'Update Conference'
expect(flash).to eq('Event types were successfully updated.')
expect(page.all('div.nested-fields').count == 2).to be true
end
end

View file

@ -38,7 +38,6 @@ feature Lodging do
expect(page.has_content?('Example Hotel')).to be true
# Add lodging
click_link 'Example Hotel'
click_link 'Edit'
fill_in 'lodging_name', with: 'New lodging'

View file

@ -1,68 +0,0 @@
require 'spec_helper'
feature Photo do
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]) }
shared_examples 'add and update photo' do
scenario 'adds a new photo', feature: true, js: true do
expected_count = Photo.count + 1
sign_in organizer
visit new_admin_conference_photo_path(conference.short_title)
file_path = Rails.root.join('app', 'assets', 'images', 'rails.png')
attach_file('photo_picture', file_path)
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
click_button 'Save Photo'
expect(flash).
to eq('Photo was successfully created.')
expect(Photo.count).to eq(expected_count)
end
scenario 'updates a photo', feature: true, js: true do
expected_count = Photo.count + 1
photo = create(:photo, conference_id: conference.id)
sign_in organizer
visit edit_admin_conference_photo_path(conference.short_title, photo.id)
file_path = Rails.root.join('app', 'assets', 'images', 'person_large.png')
attach_file('photo_picture', file_path)
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
click_button 'Save Photo'
expect(flash).
to eq('Photo was successfully updated.')
expect(Photo.count).to eq(expected_count)
end
scenario 'adds a text file', feature: true, js: true do
expected_count = Photo.count
sign_in organizer
visit new_admin_conference_photo_path(conference.short_title)
file_path = Rails.root + 'spec/fixtures/test.txt'
attach_file('photo_picture', file_path)
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
click_button 'Save Photo'
expect(flash).
to eq('A error prohibited this Photo from being saved: Picture content type is invalid. Picture is invalid.')
expect(Photo.count).to eq(expected_count)
end
end
describe 'organizer' do
it_behaves_like 'add and update photo'
end
end

View file

@ -8,7 +8,7 @@ feature Event do
let!(:participant_without_bio) { create(:user, biography: '') }
before(:each) do
conference.call_for_papers = create(:call_for_papers)
conference.call_for_paper = create(:call_for_paper)
conference.event_types = [create(:event_type)]
@options = {}

View file

@ -14,7 +14,7 @@ feature Room do
expect(page.has_no_table?('#rooms')).to be true
# Add room
click_link 'New Room'
click_link 'Add Room'
fill_in 'room_name', with: 'Auditorium'
fill_in 'room_size', with: '100'

View file

@ -15,58 +15,30 @@ feature Sponsor do
visit admin_conference_sponsors_path(
conference_id: conference.short_title)
# Add sponsors
click_link 'Add sponsor'
expect(page.all('div.nested-fields').count == 1).to be true
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example sponsor')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
set('Lorem Ipsum')
click_link 'Add Sponsor'
fill_in 'sponsor_name', with: 'SUSE'
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
attach_file 'Logo', path
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
select('Platin', from: 'sponsor_sponsorship_level_id')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
set('http://www.example.com')
click_button 'Create Sponsor'
find(:css, "select[id^='conference_sponsors_attributes_']"\
"[id$='_sponsorship_level_id']").
find(:option, 'Platin').select_option
click_button 'Update Conference'
expect(flash).to eq('Sponsorships were successfully updated.')
expect(find('div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(1) input').
value).to eq('Example sponsor')
expect(find('div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(2) textarea').
value).to eq('Lorem Ipsum')
expect(page).to have_selector("img[src*='rails.png']")
expect(find('div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(4) input').
value).to eq('http://www.example.com')
expect(find('div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(5) select:nth-of-type(1)').find('option[selected]').
text).to eq('Platin')
expect(flash).to eq('Sponsor successfully created.')
within('table#sponsors') 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).to have_selector("img[src*='rails.png']")
expect(page.assert_selector('tr', count: 2)).to be true
end
# Remove sponsor
click_link 'Remove sponsor'
expect(page.all('div.nested-fields').count == 0).to be true
find('button', text: 'Update Conference').trigger('click')
expect(flash).to eq('Sponsorships were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
click_link 'Delete'
expect(flash).to eq('Sponsor successfully deleted.')
expect(page).to_not have_selector('table#sponsors')
end
end

View file

@ -6,47 +6,60 @@ feature Track do
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'tracks' do
scenario 'adds and updates tracks', feature: true, js: true do
scenario 'adds a track', feature: true, js: true do
sign_in organizer
visit admin_conference_tracks_path(
conference_id: conference.short_title)
visit admin_conference_tracks_path(conference_id: conference.short_title)
click_link 'New Track'
# Add track
click_link 'Add track'
expect(page.all('div.nested-fields').count == 1).to be true
fill_in 'track_name', with: 'Distribution'
page.find('#track_color').set('#B94D4D')
fill_in 'track_description', with: 'Events about our Linux distribution'
click_button 'Create Track'
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example track')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
set('#ff0000')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) textarea').
set('Example room description')
expect(flash).to eq('Track successfully created.')
within('table#tracks') do
expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
end
click_button 'Update Conference'
scenario 'deletes a track', feature: true, js: true do
track = create(:track, conference_id: conference.id)
sign_in organizer
# Validations
expect(flash).to eq('Tracks were successfully updated.')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
value).to eq('Example track')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
value).to eq('#ff0000')
expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) textarea').
value).to eq('Example room description')
visit admin_conference_tracks_path(conference_id: conference.short_title)
# Remove track
click_link 'Remove track'
expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Conference'
expect(flash).to eq('Tracks were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
click_link 'Delete'
expect(flash).to eq('Track successfully deleted.')
within('table#tracks') do
expect(page.has_content?(track.name)).to be false
expect(page.has_content?(track.description)).to be false
expect(page.assert_selector('tr', count: 1)).to be true
end
end
scenario 'updates a track', feature: true, js: true do
create(:track, conference_id: conference.id)
sign_in organizer
visit admin_conference_tracks_path(conference_id: conference.short_title)
click_link 'Edit'
fill_in 'track_name', with: 'Distribution'
page.find('#track_color').set('#B94D4D')
fill_in 'track_description', with: 'Events about our Linux distribution'
click_button 'Update Track'
expect(flash).to eq('Track successfully updated.')
within('table#tracks') do
expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
end
end

View file

@ -94,7 +94,7 @@ describe 'User' do
let(:user) { create(:user, role_ids: role.id) }
let(:event) { create(:event, conference_id: conference1.id) }
let(:someevent) { create(:event, conference_id: conference2.id) }
let(:cfp) { create(:call_for_papers, conference: conference1) }
let(:cfp) { create(:call_for_paper, conference: conference1) }
it{ should_not be_able_to(:manage, conference1) }
it{ should_not be_able_to(:manage, conference2) }

View file

@ -48,7 +48,7 @@ describe Conference do
subject.start_date = Date.today + 6.weeks
subject.end_date = Date.today + 7.weeks
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today - 3.weeks)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks)
create(:event, conference: subject, created_at: Date.today)
options = {}
@ -115,7 +115,7 @@ describe Conference do
}
subject.events_per_week = db_data
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today - 3.weeks)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks)
create(:event, conference: subject, created_at: Date.today)
unconfirmed = create(:event, conference: subject)
@ -186,7 +186,7 @@ describe Conference do
subject.events_per_week = db_data
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today - 2.weeks)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 2.weeks)
create(:event, conference: subject, created_at: Date.today - 2.weeks)
@ -203,7 +203,7 @@ describe Conference do
subject.start_date = Date.today + 6.weeks
subject.end_date = Date.today + 7.weeks
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today)
create(:event, conference: subject)
result = {
@ -220,7 +220,7 @@ describe Conference do
subject.start_date = Date.today + 6.weeks
subject.end_date = Date.today + 7.weeks
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today - 3.weeks)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks)
create(:event, conference: subject, created_at: Date.today)
unconfirmed = create(:event, conference: subject)
@ -258,7 +258,7 @@ describe Conference do
subject.events_per_week = db_data
subject.save
subject.call_for_papers = create(:call_for_papers, start_date: Date.today - 3.weeks)
subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks)
create(:event, conference: subject, created_at: Date.today - 3.weeks)
@ -964,7 +964,7 @@ describe Conference do
end
it 'calculates correct for new conference' do
subject.call_for_papers = nil
subject.call_for_paper = nil
subject.venue = nil
subject.rooms = []
subject.tracks = []
@ -979,7 +979,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = nil
subject.call_for_paper = nil
subject.venue = nil
subject.rooms = []
subject.tracks = []
@ -997,7 +997,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = nil
subject.rooms = []
subject.tracks = []
@ -1016,7 +1016,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = create(:venue)
subject.rooms = []
subject.tracks = []
@ -1037,7 +1037,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = create(:venue)
subject.tracks = []
subject.event_types = []
@ -1059,7 +1059,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = create(:venue)
subject.event_types = []
subject.difficulty_levels = []
@ -1083,7 +1083,7 @@ describe Conference do
subject.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = create(:venue)
subject.difficulty_levels = []
subject.splashpage = create(:splashpage, public: false)
@ -1108,7 +1108,7 @@ describe Conference do
start_date: Date.today,
end_date: Date.today + 14)
subject.venue = create(:venue)
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
subject.venue = create(:venue)
subject.splashpage = create(:splashpage, public: true)
@ -1150,34 +1150,34 @@ describe Conference do
describe '#cfp_weeks' do
it 'calculates new year' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2013, 12, 30)
cfp.end_date = Date.new(2013, 12, 30) + 6
subject.call_for_papers = cfp
subject.call_for_paper = cfp
expect(subject.cfp_weeks).to eq(1)
end
it 'is one if start and end are 6 days apart' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 6
subject.call_for_papers = cfp
subject.call_for_paper = cfp
expect(subject.cfp_weeks).to eq(1)
end
it 'is one if start and end are the same date' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26)
subject.call_for_papers = cfp
subject.call_for_paper = cfp
expect(subject.cfp_weeks).to eq(1)
end
it 'is two if start and end are 10 days apart' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 10
subject.call_for_papers = cfp
subject.call_for_paper = cfp
expect(subject.cfp_weeks).to eq(2)
end
end
@ -1185,36 +1185,36 @@ describe Conference do
describe '#get_submissions_per_week' do
it 'does calculate correct if cfp start date is altered' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) - 7)]
expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1, 1])
end
it 'does calculate correct if cfp end date is altered' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)]
expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0, 1])
end
it 'pads with zeros if there are no submissions' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0])
end
it 'summarized correct if there are no submissions in one week' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 28
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)]
@ -1222,20 +1222,20 @@ describe Conference do
end
it 'summarized correct if there are submissions every week except the first' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)]
expect(subject.get_submissions_per_week).to eq([0, 1, 2, 2])
end
it 'summarized correct if there are submissions every week' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26))]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)]
@ -1243,29 +1243,29 @@ describe Conference do
end
it 'pads left' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)]
expect(subject.get_submissions_per_week).to eq([0, 0, 0, 1])
end
it 'pads middle' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26))]
subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)]
expect(subject.get_submissions_per_week).to eq([1, 1, 1, 2])
end
it 'pads right' do
cfp = create(:call_for_papers)
cfp = create(:call_for_paper)
cfp.start_date = Date.new(2014, 05, 26)
cfp.end_date = Date.new(2014, 05, 26) + 21
subject.call_for_papers = cfp
subject.call_for_paper = cfp
subject.events += [create(:event, created_at: Date.new(2014, 05, 26))]
expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1])
end
@ -1433,7 +1433,7 @@ describe Conference do
context 'open cfp' do
before do
subject.call_for_papers = create(:call_for_papers)
subject.call_for_paper = create(:call_for_paper)
end
it '#registration_open? is true' do

View file

@ -1,14 +0,0 @@
require 'spec_helper'
describe Photo do
describe 'validations' do
it 'has a valid factory' do
expect(build(:photo)).to be_valid
end
it 'is not valid without a picture' do
should validate_presence_of(:picture)
end
end
end

View file

@ -0,0 +1,13 @@
require 'spec_helper'
describe 'admin/call_for_papers/show' do
it 'renders call for papers details' do
assign :conference, create(:conference)
assign :call_for_paper, create(:call_for_paper)
render
expect(rendered).to include(1.day.ago.strftime('%A, %B %-d. %Y'))
expect(rendered).to include(7.days.from_now.strftime('%A, %B %-d. %Y'))
end
end

View file

@ -1,14 +0,0 @@
require 'spec_helper'
describe 'admin/callforpapers/show' do
it 'renders callforpapers details' do
assign :conference, create(:conference)
assign :cfp, create(:call_for_papers)
render
expect(rendered).to include(1.day.ago.strftime('%Y-%m-%d'))
expect(rendered).to include(7.days.from_now.strftime('%Y-%m-%d'))
expect(rendered).to include('We call for papers')
end
end

View file

@ -1,15 +0,0 @@
require 'spec_helper'
describe 'admin/social_events/index' do
it 'renders social events' do
@social_event = create(:social_event)
assign :conference, @social_event.conference
render
expect(rendered).to include('Example Social Event')
expect(rendered).to include('Lorem Ipsum Dolsum')
expect(rendered).to include("#{Date.today.strftime('%Y')}")
expect(rendered).to include("#{Date.today.strftime('%B')}")
expect(rendered).to include("#{Date.today.strftime('%-d')}")
end
end

View file

@ -24,8 +24,8 @@ describe 'conference/show.html.haml' do
start_date: Date.yesterday,
end_date: Date.tomorrow)
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
include_cfp_in_splash: true)
@conference.call_for_paper = create(:call_for_paper, conference: @conference,
include_cfp_in_splash: true)
@conference.sponsorship_levels << create(:sponsorship_level, conference: @conference)
@sponsorship_level = @conference.sponsorship_levels.first
@ -50,7 +50,7 @@ describe 'conference/show.html.haml' do
expect(view).to render_template(partial: 'conference/_registration')
end
it 'renders call_for_papers partial' do
it 'renders call_for_paper partial' do
expect(rendered).to match(/We are ready to accept your proposals for sessions!/)
end