This commit is contained in:
Stella Rouzi 2014-07-30 06:44:21 +00:00
commit 969e5944c1
102 changed files with 1262 additions and 961 deletions

View file

@ -23,6 +23,9 @@ gem 'omniauth-google-oauth2'
# Use cancancan as authorization framework # Use cancancan as authorization framework
gem 'cancancan' gem 'cancancan'
# Use rolify to set roles
gem 'rolify'
# Use transitions as state machine # Use transitions as state machine
gem 'transitions', :require => %w( transitions active_record/transitions ) gem 'transitions', :require => %w( transitions active_record/transitions )

View file

@ -296,6 +296,7 @@ GEM
request_store (1.0.6) request_store (1.0.6)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
rolify (3.4.0)
rspec (3.0.0) rspec (3.0.0)
rspec-core (~> 3.0.0) rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0) rspec-expectations (~> 3.0.0)
@ -441,6 +442,7 @@ DEPENDENCIES
rails-observers rails-observers
rdoc-generator-fivefish rdoc-generator-fivefish
redcarpet redcarpet
rolify
rspec-activemodel-mocks rspec-activemodel-mocks
rspec-rails rspec-rails
rubocop rubocop

View file

@ -1,5 +1,7 @@
class Admin::CallforpapersController < ApplicationController module Admin
before_filter :verify_organizer class CallforpapersController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
# load_and_authorize_resource :call_for_paper, class: 'CallForPapers', through: :conference
def show def show
@cfp = @conference.call_for_papers @cfp = @conference.call_for_papers
@ -50,3 +52,4 @@ class Admin::CallforpapersController < ApplicationController
end end
end end
end end
end

View file

@ -1,6 +1,7 @@
module Admin module Admin
class CampaignsController < ApplicationController class CampaignsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :campaign, through: :conference
def index def index
@conference = Conference.find_by(short_title: params[:conference_id]) @conference = Conference.find_by(short_title: params[:conference_id])

View file

@ -1,5 +1,6 @@
class Admin::ConferenceController < ApplicationController module Admin
before_filter :verify_organizer class ConferenceController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
def index def index
# Redirect to new form if there is no conference # Redirect to new form if there is no conference
@ -62,8 +63,11 @@ class Admin::ConferenceController < ApplicationController
def create def create
@conference = Conference.new(params[:conference]) @conference = Conference.new(params[:conference])
if @conference.valid? if @conference.valid?
@conference.save @conference.save
# user that creates the conference becomes organizer of that conference
current_user.add_role :organizer, @conference
redirect_to(admin_conference_path(id: @conference.short_title), redirect_to(admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully created.') notice: 'Conference was successfully created.')
else else
@ -72,7 +76,6 @@ class Admin::ConferenceController < ApplicationController
end end
def update def update
@conference = Conference.find_by(short_title: params[:id])
short_title = @conference.short_title short_title = @conference.short_title
@conference.assign_attributes(params[:conference]) @conference.assign_attributes(params[:conference])
if @conference.start_date_changed? || @conference.end_date_changed? if @conference.start_date_changed? || @conference.end_date_changed?
@ -177,3 +180,4 @@ class Admin::ConferenceController < ApplicationController
end end
end end
end end
end

View file

@ -1,5 +1,7 @@
class Admin::DietchoicesController < ApplicationController module Admin
before_filter :verify_organizer class DietchoicesController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :dietary_choice, through: :conference
def show def show
render :diets_list render :diets_list
@ -14,3 +16,4 @@ class Admin::DietchoicesController < ApplicationController
end end
end end
end end
end

View file

@ -1,5 +1,7 @@
class Admin::DifficultyLevelsController < ApplicationController module Admin
before_filter :verify_organizer class DifficultyLevelsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :difficulty_level, through: :conference
def index def index
@conference = Conference.find_by(short_title: params[:conference_id]) @conference = Conference.find_by(short_title: params[:conference_id])
@ -27,3 +29,4 @@ class Admin::DifficultyLevelsController < ApplicationController
end end
end end
end end
end

View file

@ -1,5 +1,7 @@
class Admin::EmailsController < ApplicationController module Admin
before_filter :verify_organizer class EmailsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :emails, class: EmailSettings
def update def update
@conference.email_settings.update_attributes(params[:email_settings]) @conference.email_settings.update_attributes(params[:email_settings])
@ -12,3 +14,4 @@ class Admin::EmailsController < ApplicationController
@settings = @conference.email_settings @settings = @conference.email_settings
end end
end end
end

View file

@ -0,0 +1,21 @@
module Admin
class EventTypesController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :event_type, through: :conference
def show
render :eventtypes
end
def update
@conference.update_attributes!(params[:conference])
redirect_to(admin_conference_event_types_path(
conference_id: @conference.short_title),
notice: 'Event types were successfully updated.')
rescue Exception => e
redirect_to(admin_conference_event_types_path(
conference_id: @conference.short_title),
alert: "Event types update failed: #{e.message}")
end
end
end

View file

@ -1,8 +1,8 @@
module Admin module Admin
class EventsController < ApplicationController class EventsController < ApplicationController
before_filter :verify_organizer load_resource :conference, find_by: :short_title
load_and_authorize_resource :event, through: :conference
before_action :get_event, except: [:index, :create] before_filter :authorize_conference
# FIXME: The timezome should only be applied on output, otherwise # FIXME: The timezome should only be applied on output, otherwise
# you get lost in timezone conversions... # you get lost in timezone conversions...
@ -168,15 +168,6 @@ module Admin
private private
def get_event
@event = @conference.events.find_by_id(params[:id])
if !@event
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
alert: 'Error! Could not find event!') && return
end
@event
end
def update_state(transition, notice, mail = false, subject = false, send_mail = false) def update_state(transition, notice, mail = false, subject = false, send_mail = false)
alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?) alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?)

View file

@ -1,6 +1,7 @@
module Admin module Admin
class LodgingsController < ApplicationController class LodgingsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :lodging, through: :conference
def index def index
@venue = @conference.venue @venue = @conference.venue

View file

@ -1,20 +1,19 @@
class Admin::QuestionsController < ApplicationController module Admin
before_filter :verify_organizer class QuestionsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :question, through: :conference
def index def index
@conference = Conference.find_by(short_title: params[:conference_id])
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id) @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
@questions_conference = @conference.questions @questions_conference = @conference.questions
@new_question = @conference.questions.new @new_question = @conference.questions.new
end end
def new def new
@conference = Conference.find_by(short_title: params[:conference_id])
@new_question = @conference.questions.new @new_question = @conference.questions.new
end end
def create def create
@conference = Conference.find_by(short_title: params[:conference_id])
@question = @conference.questions.new(params[:question]) @question = @conference.questions.new(params[:question])
@question.conference_id = @conference.id @question.conference_id = @conference.id
@ -30,31 +29,18 @@ class Admin::QuestionsController < ApplicationController
# GET questions/1/edit # GET questions/1/edit
def edit def edit
@conference = Conference.find_by(short_title: params[:conference_id])
@question = Question.find(params[:id]) @question = Question.find(params[:id])
if @question.global == true && !has_role?(current_user, "Admin") if @question.global == true && !(current_user.has_role? :organizer, @conference)
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
end end
end end
# PUT questions/1 # PUT questions/1
def update def update
@conference = Conference.find_by(short_title: params[:conference_id])
@question = Question.find(params[:id]) @question = Question.find(params[:id])
if @question.update_attributes(params[:question])
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
else
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
end
end
# Update questions used for the conference
def update_conference
@conference = Conference.find_by(short_title: params[:conference_id])
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
else else
@ -62,10 +48,18 @@ class Admin::QuestionsController < ApplicationController
end end
end end
# Update questions used for the conference
def update_conference
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.")
else
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.")
end
end
# DELETE questions/1 # DELETE questions/1
def destroy def destroy
if has_role?(current_user, "Admin") if can? :destroy, @question
@question = Question.find(params[:id])
# Do not delete global questions # Do not delete global questions
if @question.global == false if @question.global == false

View file

@ -1,6 +1,7 @@
module Admin module Admin
class RegistrationsController < ApplicationController class RegistrationsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference
def index def index
session[:return_to] ||= request.referer session[:return_to] ||= request.referer
@ -12,7 +13,6 @@ module Admin
end end
def change_field def change_field
@registration = Registration.find(params[:id])
field = params[:view_field] field = params[:view_field]
if @registration.send(field.to_sym) if @registration.send(field.to_sym)
@registration.update_attribute(:"#{field}", 0) @registration.update_attribute(:"#{field}", 0)
@ -26,12 +26,10 @@ module Admin
end end
def edit def edit
@registration = @conference.registrations.where('id = ?', params[:id]).first
@user = User.where('id = ?', @registration.user_id).first @user = User.where('id = ?', @registration.user_id).first
end end
def update def update
@registration = @conference.registrations.where('id = ?', params[:id]).first
@user = User.where('id = ?', @registration.user_id).first @user = User.where('id = ?', @registration.user_id).first
begin begin
@user.update_attributes!(params[:registration][:user_attributes]) @user.update_attributes!(params[:registration][:user_attributes])
@ -55,6 +53,7 @@ module Admin
def new def new
@user = User.new @user = User.new
@registration = @user.registrations.new @registration = @user.registrations.new
@registration.conference_id = @conference.id
@supporter_registration = @conference.supporter_registrations.new @supporter_registration = @conference.supporter_registrations.new
end end
@ -97,7 +96,7 @@ module Admin
end end
def destroy def destroy
if has_role?(current_user, 'Admin') if can? :destroy, @registration
registration = @conference.registrations.where(id: params[:id]).first registration = @conference.registrations.where(id: params[:id]).first
user = User.where('id = ?', registration.user_id).first user = User.where('id = ?', registration.user_id).first

View file

@ -1,5 +1,7 @@
class Admin::RoomsController < ApplicationController module Admin
before_filter :verify_organizer class RoomsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :room, through: :conference
def show def show
render :rooms_list render :rooms_list
@ -17,3 +19,4 @@ class Admin::RoomsController < ApplicationController
end end
end end
end end
end

View file

@ -1,6 +1,10 @@
module Admin module Admin
class SchedulesController < ApplicationController class SchedulesController < ApplicationController
before_filter :verify_organizer # By authorizing 'conference' resource, we can ensure there will be no unauthorized access to
# the schedule of a conference, which should not be accessed in the first place
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource class: false
skip_before_filter :verify_authenticity_token, only: [:update] skip_before_filter :verify_authenticity_token, only: [:update]
layout 'schedule' layout 'schedule'

View file

@ -1,5 +1,7 @@
class Admin::SocialEventsController < ApplicationController module Admin
before_filter :verify_organizer class SocialEventsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :social_event, through: :conference
def show def show
render :social_events_list render :social_events_list
@ -13,3 +15,4 @@ class Admin::SocialEventsController < ApplicationController
end end
end end
end end
end

View file

@ -1,15 +1,15 @@
module Admin module Admin
class SpeakersController < ApplicationController class SpeakersController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
load_resource :event, through: :conference
respond_to :js, :html respond_to :js, :html
def edit def edit
@event = @conference.events.find(params[:event_id])
@speaker = @event.event_users.where(event_role: 'speaker').first @speaker = @event.event_users.where(event_role: 'speaker').first
end end
def update def update
@event = @conference.events.find(params[:event_id])
@speaker = @event.event_users.where(event_role: 'speaker').first @speaker = @event.event_users.where(event_role: 'speaker').first
@speaker.user_id = params[:speaker][:user_id] @speaker.user_id = params[:speaker][:user_id]
@speaker.save @speaker.save

View file

@ -1,6 +1,7 @@
module Admin module Admin
class SponsorsController < ApplicationController class SponsorsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :sponsor, through: :conference
def update def update
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])

View file

@ -1,6 +1,7 @@
module Admin module Admin
class SponsorshipLevelsController < ApplicationController class SponsorshipLevelsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :sponsorship_level, through: :conference
def update def update
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])

View file

@ -1,6 +1,7 @@
module Admin module Admin
class StatsController < ApplicationController class StatsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource
load_and_authorize_resource :conference, find_by: :short_title
def index def index
@registrations = @conference.registrations.includes(:user) @registrations = @conference.registrations.includes(:user)

View file

@ -1,12 +1,13 @@
module Admin
class Admin::SupporterLevelsController < ApplicationController class Admin::SupporterLevelsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :supporter_level, through: :conference
def show def show
render :supporter_levels render :supporter_levels
end end
def update def update
begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.') redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.')
rescue => e rescue => e

View file

@ -1,16 +1,21 @@
module Admin
class Admin::SupportersController < ApplicationController class Admin::SupportersController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :supporter, through: :conference
def index def index
respond_to do |format| respond_to do |format|
format.html format.html
format.json { render json: DatatableSupporters.new(@conference.supporter_registrations, view_context) } format.json { render json: DatatableSupporters.
new(@conference.supporter_registrations, view_context) }
end end
end end
def create def create
params[:supporter_registration][:conference_id] = @conference.id params[:supporter_registration][:conference_id] = @conference.id
SupporterRegistration.create!(params[:supporter_registration]) supporter = SupporterRegistration.create!(params[:supporter_registration])
redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: "Supporter added") redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title),
notice: 'Supporter added')
end
end end
end end

View file

@ -1,6 +1,7 @@
module Admin module Admin
class TargetsController < ApplicationController class TargetsController < ApplicationController
before_filter :verify_organizer load_and_authorize_resource :conference, find_by: :short_title
authorize_resource :target, through: :conference
def index def index
end end

View file

@ -1,5 +1,7 @@
class Admin::TracksController < ApplicationController module Admin
before_filter :verify_organizer class TracksController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource through: :conference
def show def show
respond_to do |format| respond_to do |format|
@ -20,3 +22,4 @@ class Admin::TracksController < ApplicationController
end end
end end
end end
end

View file

@ -1,40 +1,44 @@
module Admin module Admin
class UsersController < ApplicationController class UsersController < ApplicationController
before_filter :verify_admin load_and_authorize_resource
def index def index
@users = User.all @users = User.all
@roles = Role.all.where(resource_type: nil)
end end
def show def show
@user = User.find(params[:id])
# Variable @show_attributes holds the attributes that are visible for the 'show' action # Variable @show_attributes holds the attributes that are visible for the 'show' action
# If you want to change the attributes that are shown in the 'show' action of users # If you want to change the attributes that are shown in the 'show' action of users
# add/remove the attributes in the following string array # add/remove the attributes in the following string array
@show_attributes = %w(name email affiliation biography registered attended created_at @show_attributes = %w(name email affiliation biography registered attended roles created_at
updated_at sign_in_count current_sign_in_at last_sign_in_at updated_at sign_in_count current_sign_in_at last_sign_in_at
current_sign_in_ip last_sign_in_ip) current_sign_in_ip last_sign_in_ip)
end end
def update def update
user = User.find(params[:id]) params[:user].delete :roles_attributes if params[:user]
user.update_attributes!(params[:user]) @user.update_attributes!(params[:user])
redirect_to admin_users_path, notice: "Updated #{user.email}" redirect_to admin_users_path, notice: "Updated #{@user.email}"
end
def add_role
role = params[:user][:roles_attributes][:"0"]
@user.add_role role['name'].parameterize.underscore.to_sym, Conference.find(role['resource_id'])
respond_to do |format|
format.html
format.js
end
end end
def edit def edit
@user = User.find(params[:id])
end
def delete
@user = User.find(params[:id])
end end
def destroy def destroy
@user = User.find(params[:id])
@user.destroy @user.destroy
redirect_to admin_users_path, notice: 'User got deleted' redirect_to admin_users_path, notice: "User #{@user.name} (#{@user.email})got deleted"
end end
end end
end end

View file

@ -1,5 +1,7 @@
class Admin::VenueController < ApplicationController module Admin
before_filter :verify_organizer class VenueController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :venue, through: :conference, singleton: true
def index def index
end end
@ -32,3 +34,4 @@ class Admin::VenueController < ApplicationController
render :venue_info render :venue_info
end end
end end
end

View file

@ -1,11 +1,13 @@
class Admin::VolunteersController < ApplicationController module Admin
class VolunteersController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource class: false, through: :conference
def index def index
@conference = Conference.find_by(short_title: params[:conference_id])
render :index render :index
end end
def show def show
@conference = Conference.find_by(short_title: params[:conference_id])
if @conference.use_vpositions if @conference.use_vpositions
@volunteers = @conference.registrations.joins(:vchoices).uniq @volunteers = @conference.registrations.joins(:vchoices).uniq
else else
@ -23,3 +25,4 @@ class Admin::VolunteersController < ApplicationController
end end
end end
end end
end

View file

@ -3,14 +3,17 @@ class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
before_filter :get_conferences before_filter :get_conferences
before_filter :store_location before_filter :store_location
before_filter :verify_user_admin
helper_method :date_string helper_method :date_string
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
check_authorization unless: :devise_controller?
def store_location def store_location
session[:return_to] = request.fullpath if request.get? and controller_name != "user_sessions" and controller_name != "sessions" session[:return_to] = request.fullpath if request.get? and controller_name != "user_sessions" and controller_name != "sessions"
end end
def after_sign_in_path_for(resource) def after_sign_in_path_for(resource)
if organizer_or_admin? && if (can? :view, Conference) &&
(!session[:return_to] || (!session[:return_to] ||
session[:return_to] && session[:return_to] &&
session[:return_to] == root_path) session[:return_to] == root_path)
@ -31,6 +34,20 @@ class ApplicationController < ActionController::Base
@conferences =Conference.all @conferences =Conference.all
end end
def authorize_conference
authorize! :update, @conference
end
def verify_user_admin
if self.class.to_s.split('::').first == 'Admin' && verify_user
unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) ||
(current_user.has_role? :info_desk, :any) ||
(current_user.has_role? :volunteers_coordinator, :any) || (current_user.is_admin)
raise CanCan::AccessDenied.new('You are not authorized to access this area!')
end
end
end
def verify_user def verify_user
:authenticate_user! :authenticate_user!
@ -39,36 +56,17 @@ class ApplicationController < ActionController::Base
return false return false
end end
@conference = Conference.find_by(short_title: params[:conference_id])
true true
end end
def organizer_or_admin? def current_ability
has_role?(current_user, 'admin') || has_role?(current_user, 'organizer') @current_ability ||= Ability.new(current_user)
end
def verify_organizer
if !verify_user
return
end
## Todo simplify this
redirect_to root_path unless has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
end
def verify_admin
if !verify_user
return
end
redirect_to root_path unless has_role?(current_user, 'admin')
end end
rescue_from CanCan::AccessDenied do |exception| rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug("Access denied!") Rails.logger.debug("Access denied!")
redirect_to root_path, alert: exception.message redirect_to root_path, alert: exception.message
end end
helper_method :organizer_or_admin?
def not_found def not_found
raise ActionController::RoutingError.new('Not Found') raise ActionController::RoutingError.new('Not Found')

View file

@ -1,11 +1,12 @@
class ConferenceController < ApplicationController class ConferenceController < ApplicationController
load_and_authorize_resource find_by: :short_title
def show def show
@conference = Conference.find_by_short_title(params[:id])
not_found unless @conference.make_conference_public? not_found unless @conference.make_conference_public?
end end
def gallery_photos def gallery_photos
@photos = Conference.find_by_short_title(params[:id]).photos @photos = @conference.photos
render "photos", formats: [:js] render "photos", formats: [:js]
end end
end end

View file

@ -1,9 +1,9 @@
class ConferenceRegistrationController < ApplicationController class ConferenceRegistrationController < ApplicationController
before_filter :verify_user before_filter :verify_user
load_resource :conference, find_by: :short_title
load_and_authorize_resource :conference_registration, class: Registration
def register def register
# TODO Figure out how to change the route's id from :id to :conference_id
@conference = Conference.find_by(short_title: params[:id])
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?', @workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
true, 'confirmed') true, 'confirmed')
@user = current_user @user = current_user
@ -23,9 +23,8 @@ class ConferenceRegistrationController < ApplicationController
# TODO this is ugly # TODO this is ugly
def update def update
conference = Conference.find_by(short_title: params[:id])
user = current_user user = current_user
registration = user.registrations.where(conference_id: conference.id).first registration = user.registrations.where(conference_id: @conference.id).first
update_registration = true update_registration = true
# First verify that the supporter code is legit # First verify that the supporter code is legit
if !params[:registration][:supporter_registration_attributes].nil? && if !params[:registration][:supporter_registration_attributes].nil? &&
@ -35,9 +34,9 @@ class ConferenceRegistrationController < ApplicationController
if regs.count != 0 if regs.count != 0
if regs.where(email: user.email).count == 0 if regs.where(email: user.email).count == 0
redirect_to(register_conference_path(id: conference.short_title), redirect_to(conference_register_path(conference_id: @conference.short_title),
alert: "This code is already in use. alert: "This code is already in use.
Please contact #{conference.contact_email} for assistance.") Please contact #{@conference.contact_email} for assistance.")
return return
end end
end end
@ -50,7 +49,7 @@ class ConferenceRegistrationController < ApplicationController
supporter_reg = params[:registration][:supporter_registration_attributes] supporter_reg = params[:registration][:supporter_registration_attributes]
params[:registration].delete :supporter_registration_attributes params[:registration].delete :supporter_registration_attributes
registration = user.registrations.new(registration_params) registration = user.registrations.new(registration_params)
if conference.use_supporter_levels? && !supporter_reg.nil? if @conference.use_supporter_levels? && !supporter_reg.nil?
if !supporter_reg[:id].blank? if !supporter_reg[:id].blank?
# Means that their supporter registration was entered ahead of time, by an admin # Means that their supporter registration was entered ahead of time, by an admin
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id]) registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
@ -58,19 +57,19 @@ class ConferenceRegistrationController < ApplicationController
raise 'Invalid code' raise 'Invalid code'
end end
else else
registration.supporter_registration = conference. registration.supporter_registration = @conference.
supporter_registrations.new(registration_params[:supporter_registration_attributes]) supporter_registrations.new(registration_params[:supporter_registration_attributes])
end end
end end
registration.conference_id = conference.id registration.conference_id = @conference.id
registration.save! registration.save!
else else
registration.update_attributes!(registration_params) registration.update_attributes!(registration_params)
end end
rescue => e rescue => e
Rails.logger.debug e.backtrace.join('\n') Rails.logger.debug e.backtrace.join('\n')
redirect_to(register_conference_path(id: conference.short_title), redirect_to(conference_register_path(conference_id: @conference.short_title),
alert: 'Registration failed:' + e.message) alert: 'Registration failed:' + e.message)
return return
end end
@ -81,18 +80,17 @@ class ConferenceRegistrationController < ApplicationController
else else
# Track ahoy event # Track ahoy event
ahoy.track 'Registered', title: 'New registration' ahoy.track 'Registered', title: 'New registration'
if conference.email_settings.send_on_registration? if @conference.email_settings.send_on_registration?
Mailbot.registration_mail(conference, current_user).deliver Mailbot.registration_mail(@conference, current_user).deliver
end end
end end
redirect_to(register_conference_path(id: conference.short_title), redirect_to(conference_register_path(conference_id: @conference.short_title),
notice: redirect_message) notice: redirect_message)
end end
def unregister def unregister
conference = Conference.find_by(short_title: params[:id])
user = current_user user = current_user
registration = user.registrations.where(conference_id: conference.id).first registration = user.registrations.where(conference_id: @conference.id).first
registration.destroy registration.destroy
redirect_to :root redirect_to :root
end end
@ -107,6 +105,7 @@ class ConferenceRegistrationController < ApplicationController
:other_dietary_choice, :handicapped_access_required, :dietary_choice_id, :other_dietary_choice, :handicapped_access_required, :dietary_choice_id,
:volunteer, :other_special_needs, :volunteer, :other_special_needs,
social_event_ids: [], social_event_ids: [],
event_ids: [],
vchoice_ids: [], vchoice_ids: [],
qanswer_ids: [], qanswer_ids: [],
qanswers_attributes: [], qanswers_attributes: [],

View file

@ -1,9 +1,11 @@
class EventAttachmentsController < ApplicationController class EventAttachmentsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :proposal, class: Event
load_and_authorize_resource :upload, class: EventAttachment, through: :proposal
before_filter :verify_user before_filter :verify_user
skip_before_filter :verify_user, only: [:show] skip_before_filter :verify_user, only: [:show]
def index def index
@proposal = Event.find(params[:proposal_id])
@uploads = @proposal.event_attachments @uploads = @proposal.event_attachments
@uploads = @uploads.map{|upload| upload.to_jq_upload } @uploads = @uploads.map{|upload| upload.to_jq_upload }
@ -14,9 +16,9 @@ class EventAttachmentsController < ApplicationController
end end
def show def show
upload = EventAttachment.find(params[:id])
if upload.public? if @upload.public?
send_file upload.attachment.path send_file @upload.attachment.path
return return
end end
@ -26,7 +28,7 @@ class EventAttachmentsController < ApplicationController
end end
if organizer_or_admin? || current_user == upload.event.submitter if organizer_or_admin? || current_user == upload.event.submitter
send_file upload.attachment.path send_file @upload.attachment.path
else else
raise ActionController::RoutingError.new('Not Found') raise ActionController::RoutingError.new('Not Found')
end end
@ -42,7 +44,6 @@ class EventAttachmentsController < ApplicationController
end end
def edit def edit
@upload = EventAttachment.find(params[:id])
end end
def create def create
@ -50,7 +51,7 @@ class EventAttachmentsController < ApplicationController
params[:event_attachment][:public] = false params[:event_attachment][:public] = false
params[:event_attachment][:event_id] = params[:proposal_id] params[:event_attachment][:event_id] = params[:proposal_id]
if !organizer_or_admin? if cannot? :create, EventAttachment
begin begin
current_user.events.find(params[:proposal_id]) current_user.events.find(params[:proposal_id])
rescue rescue
@ -83,8 +84,6 @@ class EventAttachmentsController < ApplicationController
end end
def update def update
@proposal = current_user.events.find(params[:proposal_id])
@upload = @proposal.event_attachments.find(params[:proposal_id])
respond_to do |format| respond_to do |format|
if @upload.update_attributes(params[:upload]) if @upload.update_attributes(params[:upload])
@ -98,9 +97,8 @@ class EventAttachmentsController < ApplicationController
end end
def destroy def destroy
@proposal = Event.find(params[:proposal_id])
if organizer_or_admin? || current_user == @proposal.submitter if can? :destroy, @proposal
@upload = @proposal.event_attachments.find(params[:id]) @upload = @proposal.event_attachments.find(params[:id])
end end

View file

@ -1,5 +1,6 @@
class HomeController < ApplicationController class HomeController < ApplicationController
before_filter :respond_to_options before_filter :respond_to_options
skip_authorization_check
def index def index
@today = Date.current @today = Date.current

View file

@ -1,32 +1,35 @@
class ProposalController < ApplicationController class ProposalController < ApplicationController
before_filter :verify_user, except: [:show] before_filter :verify_user, except: [:show]
before_action :set_conference, only: [:show] load_resource :conference, find_by: :short_title
before_action :set_event, only: [:show, :edit, :update, :destroy, :confirm, :restart] load_and_authorize_resource :event, parent: false
before_filter :setup
def setup
@user = current_user if current_user
@url = conference_proposal_index_path(@conference.short_title)
@event_types = @conference.event_types
end
def index def index
@events = current_user.proposals(@conference) @events = current_user.proposals(@conference)
end end
def show def show
authorize! :show, @event
# FIXME: We should show more than the first speaker # FIXME: We should show more than the first speaker
@speaker = @event.speakers.first || @event.submitter @speaker = @event.speakers.first || @event.submitter
end end
def new def new
authorize! :new, Event
@url = conference_proposal_index_path(@conference.short_title) @url = conference_proposal_index_path(@conference.short_title)
@event = Event.new @event = Event.new
end end
def edit def edit
authorize! :edit, @event
@url = conference_proposal_path(@conference.short_title, params[:id]) @url = conference_proposal_path(@conference.short_title, params[:id])
@attachments = @event.event_attachments @attachments = @event.event_attachments
end end
def create def create
authorize! :create, Event
@url = conference_proposal_index_path(@conference.short_title) @url = conference_proposal_index_path(@conference.short_title)
params[:event].delete :user params[:event].delete :user
@ -53,7 +56,7 @@ class ProposalController < ApplicationController
registration = current_user.registrations.where(conference_id: @conference.id).first registration = current_user.registrations.where(conference_id: @conference.id).first
ahoy.track 'Event submission', title: 'New submission' ahoy.track 'Event submission', title: 'New submission'
if registration.nil? if registration.nil?
redirect_to(register_conference_path(@conference.short_title), redirect_to(conference_register_path(@conference.short_title),
alert: 'Event was successfully submitted. alert: 'Event was successfully submitted.
You should register for the conference now.') You should register for the conference now.')
else else
@ -63,7 +66,6 @@ class ProposalController < ApplicationController
end end
def update def update
authorize! :update, @event
@url = conference_proposal_path(@conference.short_title, params[:id]) @url = conference_proposal_path(@conference.short_title, params[:id])
# First, update the submitter's info, if they've changed anything # First, update the submitter's info, if they've changed anything
@ -103,7 +105,6 @@ class ProposalController < ApplicationController
end end
def confirm def confirm
authorize! :update, @event
@url = conference_proposal_path(@conference.short_title, params[:id]) @url = conference_proposal_path(@conference.short_title, params[:id])
begin begin
@ -129,12 +130,12 @@ class ProposalController < ApplicationController
end end
def restart def restart
authorize! :update, @event
@url = conference_proposal_path(@conference.short_title, params[:id]) @url = conference_proposal_path(@conference.short_title, params[:id])
begin begin
@event.restart @event.restart
rescue Transitions::InvalidTransition rescue Transitions::InvalidTransition
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
error: "The proposal can't be re-submitted.") error: "The proposal can't be re-submitted.")
return return
@ -149,14 +150,4 @@ class ProposalController < ApplicationController
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.") notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.")
end end
private
def set_conference
@conference = Conference.find_by(short_title: params[:conference_id])
end
def set_event
@event = Event.find(params[:id])
end
end end

View file

@ -1,4 +1,5 @@
class ScheduleController < ApplicationController class ScheduleController < ApplicationController
authorize_resource class: false
layout "application" layout "application"
def index def index

View file

@ -1,6 +1,7 @@
module Users module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_authenticity_token skip_before_filter :verify_authenticity_token
skip_authorization_check
User.omniauth_providers.each do |provider| User.omniauth_providers.each do |provider|
define_method(provider) { handle(provider) } define_method(provider) { handle(provider) }

View file

@ -2,16 +2,158 @@ class Ability
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
# guest user (not logged in) # The first argument to `can` is the action you are giving the user permission to do.
user ||= User.new # If you pass :manage it will apply to every action. Other common actions here are
if user.admin? || user.organizer? # :read, :create, :update and :destroy.
# An admin can manage everything #
can :manage, :all # The second argument is the resource the user can perform the action on. If you pass
else # :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
can [:update, :destroy], Event do |event| #
event.users.include?(user) # The third argument is an optional hash of conditions to further filter the objects.
# For example, here the user can only update published articles.
#
# can :update, Article, :published => true
#
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
# Order Abilities
# (Check https://github.com/CanCanCommunity/cancancan/wiki/Ability-Precedence)
user ||= User.new # guest user (not logged in)
# Check roles of user, using rolify. Role name is *case sensitive*
# user.is_organizer? or user.has_role? :organizer
# We only assign roles per conference, so:
# user.is_cfp_of? Conference.find(1) or user.has_role? :cfp, @conference
# user.is_info_desk_of? @conference
# user.is_volunteer_coordinator_of? @conference
# user.is_attendee_of? @conference
# The following is wrong because a user will only have 'cfp' role for a specific conference
# user.is_cfp? # Always FALSE
# Ids of all the conferences for which the user has an 'organizer' role
conf_ids_for_organizer =
Conference.with_role(:organizer, user).pluck(:id) unless user.new_record?
# Ids of the venues of the conference for which (conferences) the user has an 'organizer' role
conf_ids_for_organizer_venue =
Conference.with_role(:organizer, user).pluck(:venue_id) unless user.new_record?
# Ids of all the conferences for which the user has a 'cfp' role
conf_ids_for_cfp =
Conference.with_role(:cfp, user).pluck(:id) unless user.new_record?
# Ids of all the conferences for which the user has an 'info_desk' role
conf_ids_for_info_desk =
Conference.with_role(:info_desk, user).pluck(:id) unless user.new_record?
# Ids of all the conferences for which the user has a 'volunteer_coordinator' role
conf_ids_for_volunteer_coordinator =
Conference.with_role(:volunteer_coordinator, user).pluck(:id) unless user.new_record?
event_ids_for_user =
EventUser.where(user_id: user.id).pluck(:event_id)
## Abilities for everyone (incl. GUESTS - not logged in users)
can :show, Conference, make_conference_public: true
can :show, Event, state: 'confirmed'
can :index, :schedule
## Abilities for signed in users
unless user.new_record?
# Conference Registration
can [:register, :update, :unregister], Registration, user_id: user.id
# Proposals
# Users can edit their own proposals
# Organizer and CfP team can edit any proposal they want
# Can manage an event if the user is a speaker or a submitter of that event
can :create, Event
can :manage, Event do |event|
event.event_users.where(:user_id => user.id).present?
end end
can [:create, :read], Event
can :manage, EventAttachment do |ea|
Event.find(ea.event_id).event_users.where(user_id: user.id).present?
end
can :create, EventAttachment
end
## Abilities for admins
if user.is_admin # is_admin is an attribute of User
can :create, Conference
can :index, Conference # this will allow the Conference to appear in the menu
can :show, Conference # for /admin/conference overview
can :manage, User # to make other users admins
end
## Abilities for ORGANIZER
# If a user is organizer of a conference, they can manage everything related to this conference
if user.has_role? :organizer, :any
can :manage, :all, conference_id: conf_ids_for_organizer
# Registrations controller authorizes conference resource too, so we don't have to worry about
# accessing the new registration page of a conference we don't have access to
can :create, Registration, conference_id: conf_ids_for_organizer
# Override previous can because
# Models Conference, Venue, User, Schedule do not have a 'conference_id' attribute
cannot :manage, Conference
cannot :manage, Venue
cannot :manage, User
cannot :manage, :schedule
can :manage, :schedule
# Authorize explicitely, so that it doesn't look for a 'conference_id'
can :manage, :volunteer
# Authorize Conference by its 'id' attribute
can :manage, Conference, id: conf_ids_for_organizer
# Authorize venues of conferences, which user can manage
can :manage, Venue, id: conf_ids_for_organizer_venue
# id: Conference.where(id: conf_ids_for_organizer).map(&:venue_id)
# User can view the admin 'users' page if he is an organizer for any conference
can :manage, User
# To assign roles to users
# can :manage, Role, resource_id: conf_ids_for_organizer
end
## Abilities for CfP
# A user can manage events of the conference, for which conference the user has a 'cfp' role
if user.has_role? :cfp, :any
# Can view dashboard for specific conference (show) and for all conference (index)
can [:index, :show], Conference, id: conf_ids_for_cfp
can :manage, Event, conference_id: conf_ids_for_cfp
can :manage, CallForPapers, conference_id: conf_ids_for_cfp
can :manage, EventType, conference_id: conf_ids_for_cfp
can :manage, Track, conference_id: conf_ids_for_cfp
can :manage, DifficultyLevel, conference_id: conf_ids_for_cfp
can :manage, :schedule
can :manage, EmailSettings, conference_id: conf_ids_for_cfp
can :index, User
end
## Abilities for Info Desk
if user.has_role? :info_desk, :any
can [:index, :show], Conference, id: conf_ids_for_info_desk
can :manage, Registration, conference_id: conf_ids_for_info_desk
can :manage, Question, conference_id: conf_ids_for_info_desk
# Previously we authorized Registrations of a specific conference, but that doesn't work
# if we want to create a new one, which does not belong to any conference yet
# Registrations controller authorizes conference resource too, so we don't have to worry about
# accessing the new registration page of a conference we don't have access to
can :create, Registration, conference_id: conf_ids_for_info_desk
can :index, User
end
## Abilities for Volunteer Coordinator
if user.has_role? :volunteer_coordinator, :any
can [:index, :show], Conference, id: conf_ids_for_volunteer_coordinator
can :manage, Vposition, conference_id: conf_ids_for_volunteer_coordinator
can :manage, Vday, conference_id: conf_ids_for_volunteer_coordinator
can :manage, :volunteer
end end
end end
end end

View file

@ -4,6 +4,7 @@
class Conference < ActiveRecord::Base class Conference < ActiveRecord::Base
require 'uri' require 'uri'
serialize :events_per_week, Hash serialize :events_per_week, Hash
resourcify # Needed to call 'Conference.with_role' in /models/ability.rb and admin_ability.rb
attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path, attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path,
:start_date, :end_date, :rooms_attributes, :tracks_attributes, :start_date, :end_date, :rooms_attributes, :tracks_attributes,

View file

@ -6,6 +6,7 @@ class EventAttachment < ActiveRecord::Base
has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
do_not_validate_attachment_file_type :attachment
def to_jq_upload def to_jq_upload
{ {

View file

@ -1,4 +1,10 @@
class Role < ActiveRecord::Base class Role < ActiveRecord::Base
attr_accessible :name attr_accessible :name, :description
has_and_belongs_to_many :users has_and_belongs_to_many :users
belongs_to :resource, polymorphic: true
scopify
LABELS = ['Participant', 'Attendee', 'Volunteer', 'Speaker', 'Sponsor', 'Press',
'Organizer', 'CfP', 'Info Desk', 'Volunteers Coordinator']
end end

View file

@ -1,7 +1,10 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
rolify
include Gravtastic include Gravtastic
gravtastic size: 32 gravtastic size: 32
before_create :setup_role
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, # :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable # :lockable, :timeoutable and :omniauthable
@ -9,22 +12,19 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable, omniauth_providers: [:novell, :google, :facebook] :omniauthable, omniauth_providers: [:novell, :google, :facebook]
has_and_belongs_to_many :roles
has_many :openids
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids, attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids,
:name, :email_public, :biography, :nickname, :affiliation :name, :email_public, :biography, :nickname, :affiliation
has_and_belongs_to_many :roles
has_many :openids
has_many :event_users, dependent: :destroy has_many :event_users, dependent: :destroy
has_many :events, -> { uniq }, through: :event_users has_many :events, -> { uniq }, through: :event_users
has_many :registrations, dependent: :destroy has_many :registrations, dependent: :destroy
has_many :votes, dependent: :destroy has_many :votes, dependent: :destroy
has_many :voted_events, through: :votes, source: :events has_many :voted_events, through: :votes, source: :event
accepts_nested_attributes_for :roles accepts_nested_attributes_for :roles
before_create :setup_role
validates :name, presence: true validates :name, presence: true
# Searches for user based on email. Returns found user or new user. # Searches for user based on email. Returns found user or new user.
@ -47,26 +47,12 @@ class User < ActiveRecord::Base
user user
end end
def role?(role)
Rails.logger.debug('Checking role in user')
!!roles.find_by_name(role.to_s.downcase.camelize)
end
def admin?
role?('Admin')
end
def organizer?
role?('Organizer')
end
def get_roles def get_roles
roles roles
end end
def setup_role def setup_role
roles << Role.where(name: 'Admin') if User.count == 0 self.is_admin = true if User.count == 0
roles << Role.where(name: 'Participant') if roles.empty?
end end
def self.prepare(params) def self.prepare(params)

View file

@ -23,7 +23,7 @@
= link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title']) = link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title'])
%li{'class'=>class_for_todo(conference_progress['event_types'])} %li{'class'=>class_for_todo(conference_progress['event_types'])}
%span{'class'=>icon_for_todo(conference_progress['event_types'])} %span{'class'=>icon_for_todo(conference_progress['event_types'])}
= link_to 'Add event types', admin_conference_eventtypes_path(conference_progress['short_title']) = link_to 'Add event types', admin_conference_event_types_path(conference_progress['short_title'])
%li{'class'=>class_for_todo(conference_progress['difficulty_levels'])} %li{'class'=>class_for_todo(conference_progress['difficulty_levels'])}
%span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])} %span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])}
= link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title']) = link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title'])

View file

@ -1,5 +1,5 @@
.row .row
.col-md-8 .col-md-8
= semantic_form_for(@conference, url: admin_conference_eventtypes_path(@conference.short_title, @conference.event_types)) do |f| = semantic_form_for(@conference, url: admin_conference_event_types_path(@conference.short_title, @conference.event_types)) do |f|
= dynamic_association :event_types, "Event Types", f = dynamic_association :event_types, "Event Types", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -18,11 +18,13 @@
= ',' = ','
= label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}" = label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}"
- if can? :update, q
%td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q), %td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
class: 'btn btn-primary', class: 'btn btn-primary',
disabled: q.global == true && !has_role?(current_user, 'Admin') disabled: q.global == true
- if can? :destroy, q
%td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q), %td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
method: :delete, remote: true, class: 'btn btn-danger', method: :delete, remote: true, class" 'btn btn-danger',
confirm: "Delete question '#{q.title}'?", confirm: "Delete question '#{q.title}'?",
disabled: q.global == true && !has_role?(current_user, "Admin") disabled: q.global == true

View file

@ -7,7 +7,9 @@
= "(#{@registrations.length})" = "(#{@registrations.length})"
= " - Attended (#{@attended})" = " - Attended (#{@attended})"
.btn-group.pull-right .btn-group.pull-right
- if can? :create, Registration
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default" = link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
- if can? :read, Registration
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default" = link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default" = link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
%table.table.table-bordered.table-striped.table-hover#registrations %table.table.table-bordered.table-striped.table-hover#registrations

View file

@ -0,0 +1,11 @@
= semantic_form_for(user, url: add_role_admin_user_path(user), remote: true) do |f|
.pull-left
= f.action :submit, as: :button, label: 'Add Role', button_html: {value: 'Save', class: 'btn btn-success'}
%br
%br
= f.fields_for :roles, Role.new do |role|
= role.input :name, label: 'Select role', collection: Role::LABELS
= role.label 'Select Conference'
%br
= role.input :resource, label: false, collection: Conference.all.map { |c| [c.short_title, c.id] }
%br

View file

@ -1,8 +1,13 @@
= semantic_form_for [:admin, @user] do |f| = semantic_form_for [:admin, @user] do |f|
= f.inputs "Basic Information" do = f.inputs 'Basic Information' do
= f.input :name, :as => :string = f.input :name, :as => :string
= f.input :email = f.input :email
= f.input :affiliation, :as => :string = f.input :affiliation, as: :string
= f.input :biography, :input_html => {:rows => 10} = f.input :biography, input_html: { rows: 5, "onkeyup" => "word_count(this, 'biography-count', 150)" }
You have used
%span#biography-count #{@user.biography_word_count}
words. Biographies are limited to 150 words.
%br
%br
= f.actions do = f.actions do
= f.action :submit, :button_html => {:class => "btn btn-primary"} = f.action :submit, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,10 @@
- user ||= @user
.roles{ id: 'current_roles' }
= semantic_form_for(user, url: admin_user_path(user)) do |f|
= f.action :submit, as: :button, label: 'Update Roles', button_html: {value: 'Save', class: 'btn btn-primary'}
= f.inputs "Roles for #{@user.name}" do
- user.roles.each do |role|
%br
= hidden_field_tag "user[role_ids][]", nil
= check_box_tag "user[role_ids][]", role.id, user.roles.include?(role), id: dom_id(role)
= label_tag dom_id(role), "#{ role.name.capitalize } for #{ role.resource_type.constantize.find(role.resource_id).short_title }"

View file

@ -0,0 +1 @@
$('#current_roles').html("<%= escape_javascript(render partial: 'user_roles').html_safe %>");

View file

@ -0,0 +1,19 @@
.row
.col-md-12
.tabbable
%ul.nav.nav-tabs
%li.active
= link_to 'User', '#user-content', 'data-toggle'=>'tab'
%li= link_to 'Roles', '#roles-content', 'data-toggle'=>'tab'
.tab-content
#user-content.tab-pane.active
= render partial: 'form'
#roles-content.tab-pane
.row
.col-md-6
%br
= render partial: 'user_roles', locals: { user: @user }
.col-md-6
%br
= render partial: 'add_roles', locals: { user: @user }

View file

@ -5,7 +5,7 @@
- if @users - if @users
= "(#{@users.length})" = "(#{@users.length})"
= link_to "New User", new_admin_user_path, :class => "btn btn-success pull-right" = link_to "New User", new_admin_user_path, class: 'btn btn-success pull-right'
.well .well
%table.table.table-striped.table-bordered.table-hover#users %table.table.table-striped.table-bordered.table-hover#users
%thead %thead
@ -40,37 +40,21 @@
%td %td
= user.registrations.count = user.registrations.count
%td %td
.modal.fade{:id => "user-role-selection-#{user.id}", "role" => "dialog", "aria-hidden" => "true"} - if can? :update, Role
.modal-dialog = link_to "#{ user.roles.present? ? (user.roles.map { |role| "#{ role.name.titleize }(#{ role.resource_type.constantize.find(role.resource_id).short_title })" }.join ', ') : 'Add Role'}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}"
.modal-content
.modal-header
%button{"type"=>"button", :class=>"close", "data-dismiss"=>"modal", "aria-hidden"=>"true"}
×
%h3{:id => "role-selector-header-#{user.id}"}
Modifying Roles
.modal-body
- if current_user == user
You cannot modify your own role!
%br
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
Cancel
- else - else
= "Give #{user.name} (#{user.email}) the following roles:" = user.roles.map { |role| "#{ role.name.capitalize } for #{ role.resource_type.constantize.find(role.resource_id).short_title }" }.join ', '
= semantic_form_for(user, :url => admin_user_path(user), :method => :put) do |f| - if can? :show, user
= f.input :roles, :label => false
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
Cancel
= f.action :submit, :as => :button, :button_html => {:value => "Save", :class => "btn btn-primary"}
=link_to "#{user.roles.map { |role| role.name }.join ', '}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}"
%td %td
= link_to "Edit", edit_admin_user_path(user) = link_to "View", admin_user_path(user), class: 'btn btn-success'
- if can? :update, user
%td %td
= link_to "View", admin_user_path(user) = link_to "Edit", edit_admin_user_path(user), class: 'btn btn-primary'
%td - if can? :destroy, user
- if current_user.id == user.id or user.role_ids.include? 3 %td= link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
- else - else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" %td= link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
:javascript :javascript

View file

@ -1,7 +1,14 @@
- if can? :update, @user
.pull-right
= link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary'
%table.table %table.table
- @show_attributes.each do |attr| - @show_attributes.each do |attr|
%tr %tr
%td %td{style: 'width:20%'}
%b %b
= attr.capitalize.gsub('_', ' ') = attr.capitalize.gsub('_', ' ')
- if attr == 'roles'
%td
= @user.send(attr).map { |role| "#{ role.name.capitalize } of #{ role.resource_type.constantize.find(role.resource_id).short_title }"}.join(', ')
- else
%td= @user.send(attr) %td= @user.send(attr)

View file

@ -13,7 +13,7 @@
-else -else
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } %h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
- if @conference.registration_open? - if @conference.registration_open?
= link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank' = link_to "Register for #{@conference.short_title}", conference_register_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
- if @conference.use_supporter_levels? - if @conference.use_supporter_levels?
- if @conference.include_tickets_in_splash? - if @conference.include_tickets_in_splash?
= render 'tickets' = render 'tickets'

View file

@ -1,6 +1,6 @@
.row .row
.col-md-12 .col-md-12
= semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :patch }) do |f| = semantic_form_for(@registration, :url => conference_register_path(@conference.short_title), :html => { :method => :patch }) do |f|
.tabbable .tabbable
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li.active %li.active
@ -16,7 +16,7 @@
= render 'conference_registration/volunteer', :f => f = render 'conference_registration/volunteer', :f => f
- if @registered - if @registered
= f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" } = f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" }
= link_to "Unregister", register_conference_path(@conference.short_title),:method => :delete, :class => "btn btn-danger", = link_to "Unregister", conference_register_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
:confirm => "Are you sure you want to unregister?" :confirm => "Are you sure you want to unregister?"
- else - else
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' } = f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }

View file

@ -25,9 +25,9 @@
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
- if conference.registration_open? - if conference.registration_open?
- if conference.user_registered?(current_user) - if conference.user_registered?(current_user)
= link_to "Modify Registration", register_conference_path(conference.short_title), :class =>"btn btn-default" = link_to "Modify Registration", conference_register_path(conference.short_title), :class =>"btn btn-default"
- else - else
= link_to "Register", register_conference_path(conference.short_title), :class =>"btn btn-success" = link_to "Register", conference_register_path(conference.short_title), :class =>"btn btn-success"
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public = link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public
- if !current_user.nil? && current_user.proposal_count(conference) > 0 - if !current_user.nil? && current_user.proposal_count(conference) > 0
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" = link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"

View file

@ -10,83 +10,104 @@
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
All Conferences All Conferences
- @conferences.each do |conference| - @conferences.each do |conference|
- if can? :show, conference
%li %li
= link_to(admin_conference_path(conference.short_title)) do = link_to(admin_conference_path(conference.short_title)) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-cog
Manage Manage
= conference.short_title = conference.short_title
- if can? :create, Conference
%li %li
= link_to(new_admin_conference_path) do = link_to(new_admin_conference_path) do
%span.glyphicon.glyphicon-plus %span.glyphicon.glyphicon-plus
New Conference New Conference
%hr %hr
- if can? :show, @conference
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"} %li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
= link_to(admin_conference_path(@conference.short_title)) do = link_to(admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-dashboard %span.glyphicon.glyphicon-dashboard
Manage Manage
- if can? :index, Event, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
= link_to(admin_conference_events_path(@conference.short_title)) do = link_to(admin_conference_events_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment %span.glyphicon.glyphicon-comment
Events Events
- if can? :index, @conference => Registration
%li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))}
= link_to(admin_conference_registrations_path(@conference.short_title)) do = link_to(admin_conference_registrations_path(@conference.short_title)) do
%span.glyphicon.glyphicon-user %span.glyphicon.glyphicon-user
Registrations Registrations
- if can? :update, :schedule
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))} %li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
= link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do = link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do
%span.glyphicon.glyphicon-calendar %span.glyphicon.glyphicon-calendar
Schedule Schedule
- if can? :index, Campaign, conference_id: @conference.id
%li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))} %li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))}
= link_to(admin_conference_campaigns_path(@conference.short_title)) do = link_to(admin_conference_campaigns_path(@conference.short_title)) do
%span.glyphicon.glyphicon-bullhorn %span.glyphicon.glyphicon-bullhorn
Campaigns Campaigns
%hr %hr
- if can? :update, Conference, id: @conference.id
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"} %li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
= link_to(edit_admin_conference_path(@conference.short_title)) do = link_to(edit_admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-cog
Settings Settings
- if can? :index, Target, conference_id: @conference.id
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"} %li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
= link_to(admin_conference_targets_path(@conference.short_title)) do = link_to(admin_conference_targets_path(@conference.short_title)) do
%span.glyphicon.glyphicon-flag %span.glyphicon.glyphicon-flag
Targets Targets
- if can? :index, Venue, id: @conference.venue.id
%li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"} %li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"}
= link_to(admin_conference_venue_info_path(@conference.short_title)) do = link_to(admin_conference_venue_info_path(@conference.short_title)) do
%span.glyphicon.glyphicon-road %span.glyphicon.glyphicon-road
Venue Venue
%span.small.glyphicon.glyphicon-chevron-right %span.small.glyphicon.glyphicon-chevron-right
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav %ul.nav.nav-stacked.nav-pills.small.collapse.subNav
- if can? :index, Room, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))}
= link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title)
- if can? :index, Lodging, venue_id: @conference.venue.id
%li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) }
= link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title) = link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title)
- if can? :index, SponsorshipLevel, conference_id: @conference.id
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" } %li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" }
= link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do = link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do
%span.glyphicon.glyphicon-star %span.glyphicon.glyphicon-star
Sponsorship Sponsorship
%span.small.glyphicon.glyphicon-chevron-right %span.small.glyphicon.glyphicon-chevron-right
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav %ul.nav.nav-stacked.nav-pills.small.collapse.subNav
- if can? :index, Sponsor, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title) = link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
- if can? :index, SupporterLevel, conference_id: @conference.id
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) } %li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do = link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
%span.glyphicon.glyphicon-usd %span.glyphicon.glyphicon-usd
Supporter Levels Supporter Levels
- if can? :index, EmailSettings, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))}
= link_to(admin_conference_emails_path(@conference.short_title)) do = link_to(admin_conference_emails_path(@conference.short_title)) do
%span.glyphicon.glyphicon-envelope %span.glyphicon.glyphicon-envelope
E-Mails E-Mails
- if can? :index, CallForPapers, conference_id: @conference.id
%li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"} %li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"}
= link_to(admin_conference_callforpapers_path(@conference.short_title)) do = link_to(admin_conference_callforpapers_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment %span.glyphicon.glyphicon-comment
Call for papers Call for papers
%span.small.glyphicon.glyphicon-chevron-right %span.small.glyphicon.glyphicon-chevron-right
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav %ul.nav.nav-stacked.nav-pills.small.collapse.subNav
- if can? :index, @conference => Track
%li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))}
= link_to 'Tracks', admin_conference_tracks_path(@conference.short_title) = link_to 'Tracks', admin_conference_tracks_path(@conference.short_title)
%li{:class=> active_nav_li(admin_conference_eventtypes_path(@conference.short_title))} - if can? :index, EventType, conference_id: @conference.id
= link_to 'Event types', admin_conference_eventtypes_path(@conference.short_title) %li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))}
= link_to 'Event types', admin_conference_event_types_path(@conference.short_title)
- if can? :index, DifficultyLevel, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))}
= link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title) = link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title)
- if can? :index, Question, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))}
= link_to(admin_conference_questions_path(@conference.short_title)) do = link_to(admin_conference_questions_path(@conference.short_title)) do
%span.glyphicon.glyphicon-question-sign %span.glyphicon.glyphicon-question-sign

View file

@ -10,15 +10,18 @@
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
All Conferences All Conferences
- @conferences.each do |conference| - @conferences.each do |conference|
- if can? :show, conference
%li %li
= link_to(admin_conference_path(conference.short_title)) do = link_to(admin_conference_path(conference.short_title)) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-cog
Manage Manage
= conference.short_title = conference.short_title
- if can? :create, Conference
%li %li
= link_to(new_admin_conference_path) do = link_to(new_admin_conference_path) do
%span.glyphicon.glyphicon-plus %span.glyphicon.glyphicon-plus
New Conference New Conference
- if can? :index, User
%hr %hr
%li %li
= link_to(admin_users_path) do = link_to(admin_users_path) do

View file

@ -11,13 +11,13 @@
= link_to(destroy_user_session_path, :method=>'delete') do = link_to(destroy_user_session_path, :method=>'delete') do
%span.glyphicon.glyphicon-minus %span.glyphicon.glyphicon-minus
Sign out Sign out
-if has_role?(current_user, "admin") || has_role?(current_user, "organizer") - if can? :index, Conference
%li.divider %li.divider
%li %li
= link_to(admin_conference_index_path()) do = link_to(admin_conference_index_path()) do
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
Administration Administration
-if @conference and @conference.id -if @conference and @conference.id and can? :index, @conference
%li %li
= link_to(admin_conference_path(@conference.short_title)) do = link_to(admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-cog

View file

@ -45,7 +45,7 @@
data.formData = inputs.serializeArray(); data.formData = inputs.serializeArray();
}); });
$.getJSON($('#fileupload').prop('action'), function (files) { $.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('fileupload'), var fu = $('#fileupload').data('blueimpFileupload'),
template; template;
fu._adjustMaxNumberOfFiles(-files.length); fu._adjustMaxNumberOfFiles(-files.length);
template = fu._renderDownload(files) template = fu._renderDownload(files)

View file

@ -1,20 +1,20 @@
= semantic_form_for(@event, :url => @url) do |f| = semantic_form_for(@event, :url => @url) do |f|
%section#basic %section#basic
= f.inputs :name => "Session Information" do = f.inputs :name => "Session Information" do
- if !@conference.call_for_papers.schedule_changes && @event.state == "confirmed" && !organizer_or_admin? - if can? :update, @event or can? :create, @event
= f.input :title, :as => :string, :required => true
- else
Title: #{@event.title} Title: #{@event.title}
%br %br
%br %br
- else
= f.input :title, :as => :string, :required => true
= f.input :subtitle, :as => :string = f.input :subtitle, :as => :string
%section#details %section#details
- if (@event.state === "unconfirmed" || @event.state === "confirmed") && !organizer_or_admin? && !@conference.call_for_papers.schedule_changes - if can? :update, @event or can? :create, @event
= f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type"
- else
Event type: #{@event.event_type.title} Event type: #{@event.event_type.title}
%br %br
%br %br
- else
= f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type"
= f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.use_difficulty_levels = f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.use_difficulty_levels
= f.input :require_registration = f.input :require_registration
= f.input :abstract, :input_html => {:rows => 5, :class => "span11"}, = f.input :abstract, :input_html => {:rows => 5, :class => "span11"},

View file

@ -27,7 +27,7 @@
(Pre-registered: #{pre_registered(event).count}) (Pre-registered: #{pre_registered(event).count})
- if event.confirmed? && !@conference.user_registered?(current_user) - if event.confirmed? && !@conference.user_registered?(current_user)
%br %br
= link_to "Register to attend", register_conference_path(@conference.short_title), :style => "font-size:10px;" = link_to "Register to attend", conference_register_path(@conference.short_title), :style => "font-size:10px;"
%td %td
.pull-right .pull-right
- if event.transition_possible? :confirm - if event.transition_possible? :confirm

View file

@ -7,7 +7,7 @@
%small %small
= @event.subtitle = @event.subtitle
= link_to "Schedule", conference_schedule_path(@conference.short_title), :class =>"btn btn-success pull-right" = link_to "Schedule", conference_schedule_path(@conference.short_title), :class =>"btn btn-success pull-right"
- if has_role?(current_user, "admin") - if can? :edit, @event
= link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right" = link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right"
.row .row
.col-md-3 .col-md-3
@ -37,7 +37,7 @@
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"} %span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
= @event.difficulty_level.title = @event.difficulty_level.title
- if @event.require_registration - if @event.require_registration
= link_to "Registration required!", register_conference_path(@conference.short_title), :class => "btn btn-xs btn-warning" = link_to "Registration required!", conference_register_path(@conference.short_title), :class => "btn btn-xs btn-warning"
.col-md-9 .col-md-9
.row .row
.col-md-12 .col-md-12

View file

@ -0,0 +1,8 @@
Rolify.configure do |config|
# By default ORM adapter is ActiveRecord. uncomment to use mongoid
# config.use_mongoid
# Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
# Enable this feature _after_ running rake db:migrate as it relies on the roles table
config.use_dynamic_shortcuts
end

View file

@ -5,7 +5,11 @@ Osem::Application.routes.draw do
path: 'accounts' path: 'accounts'
namespace :admin do namespace :admin do
resources :users resources :users do
member do
patch 'add_role' => 'users#add_role'
end
end
resources :people resources :people
resources :conference do resources :conference do
resource :schedule, only: [:show, :update] resource :schedule, only: [:show, :update]
@ -37,7 +41,7 @@ Osem::Application.routes.draw do
resources :campaigns resources :campaigns
resources :eventtypes, only: [:show, :index] do resources :event_types, only: [:show, :index] do
collection do collection do
patch :update patch :update
end end
@ -88,10 +92,10 @@ Osem::Application.routes.draw do
resource :schedule, only: [] do resource :schedule, only: [] do
get "/" => "schedule#index" get "/" => "schedule#index"
end end
member do
get "/register" => "conference_registration#register" get "/register" => "conference_registration#register"
patch "/register" => "conference_registration#update" patch "/register" => "conference_registration#update"
delete "/register" => "conference_registration#unregister" delete "/register" => "conference_registration#unregister"
member do
get "gallery_photos" get "gallery_photos"
end end
end end

View file

@ -0,0 +1,10 @@
class AddDescriptionAndResourceToRoles < ActiveRecord::Migration
def change
add_column :roles, :description, :string
add_reference :roles, :resource, polymorphic: true
add_index(:roles, :name)
add_index(:roles, [:name, :resource_type, :resource_id])
add_index(:roles_users, [:user_id, :role_id])
end
end

View file

@ -0,0 +1,5 @@
class AddIsAdminToUsers < ActiveRecord::Migration
def change
add_column :users, :is_admin, :boolean
end
end

View file

@ -352,15 +352,23 @@ ActiveRecord::Schema.define(version: 20140724113107) do
create_table "roles", force: true do |t| create_table "roles", force: true do |t|
t.string "name" t.string "name"
t.string "description"
t.integer "resource_id"
t.string "resource_type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
add_index "roles", ["name"], name: "index_roles_on_name"
create_table "roles_users", id: false, force: true do |t| create_table "roles_users", id: false, force: true do |t|
t.integer "role_id" t.integer "role_id"
t.integer "user_id" t.integer "user_id"
end end
add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id"
create_table "rooms", force: true do |t| create_table "rooms", force: true do |t|
t.string "guid", null: false t.string "guid", null: false
t.integer "conference_id" t.integer "conference_id"
@ -466,6 +474,7 @@ ActiveRecord::Schema.define(version: 20140724113107) do
t.string "tshirt" t.string "tshirt"
t.string "languages" t.string "languages"
t.text "volunteer_experience" t.text "volunteer_experience"
t.boolean "is_admin"
end end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true

View file

@ -5,22 +5,28 @@
# #
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first) # Mayor.create(name: 'Emanuel', city: cities.first)
Role.create(name: "Participant")
Role.create(name: "Organizer")
Role.create(name: "Admin")
qtype_yesno = QuestionType.create(title: "Yes/No") # Questions
QuestionType.create(title: "Single Choice") qtype_yesno = QuestionType.create(title: 'Yes/No')
QuestionType.create(title: "Multiple Choice") qtype_single = QuestionType.create(title: 'Single Choice')
qtype_multiple = QuestionType.create(title: 'Multiple Choice')
answer_yes = Answer.create(title: "Yes") <<<<<<< HEAD
answer_no = Answer.create(title: "No") questions_yes_no.each do |i|
q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"] =======
answer_yes = Answer.create(title: 'Yes')
answer_no = Answer.create(title: 'No')
questions_yes_no = ['Do you need handicapped access to the venue?',
'Are you attending with partner?', 'Will you attend the social event(s)?',
'Will you stay at suggested hotel?']
questions_yes_no.each do |i| questions_yes_no.each do |i|
q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true) q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
>>>>>>> rework roles with rolify
Qanswer.create(question_id: q.id, answer_id: answer_no.id) Qanswer.create(question_id: q.id, answer_id: answer_no.id)
Qanswer.create(question_id: q.id, answer_id: answer_yes.id) Qanswer.create(question_id: q.id, answer_id: answer_yes.id)
end end

View file

@ -3,16 +3,14 @@ require 'spec_helper'
describe Admin::ConferenceController do describe Admin::ConferenceController do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let(:conference) { create(:conference) } let(:conference) { create(:conference) }
let(:admin) { create(:admin) } let!(:participant_role) { create(:participant_role) }
let(:organizer) { create(:organizer) } let!(:organizer_role) { create(:organizer_conference_1_role, resource_id: conference.id) }
let(:organizer) { create(:organizer_conference_1, is_admin: true) }
let(:participant) { create(:participant) } let(:participant) { create(:participant) }
shared_examples 'access as administration or organizer' do shared_examples 'access as administration' do
describe 'PATCH #update' do describe 'PATCH #update' do
@ -216,59 +214,64 @@ describe Admin::ConferenceController do
describe 'administrator access' do describe 'administrator access' do
before do before do
sign_in(admin)
end
it_behaves_like 'access as administration or organizer'
end
describe 'organizer access' do
before(:each) do
sign_in(organizer) sign_in(organizer)
end end
it_behaves_like 'access as administration or organizer' it_behaves_like 'access as administration'
end end
shared_examples 'access as participant or guest' do |success_path| shared_examples 'access as participant or guest' do |path, message|
describe 'GET #show' do describe 'GET #show' do
it 'requires admin privileges' do it 'requires organizer privileges' do
get :show, id: conference.short_title get :show, id: conference.short_title
expect(response).to redirect_to(send(success_path)) expect(response).to redirect_to(send(path))
if message
expect(flash[:alert]).to match(/#{message}/)
end
end end
end end
describe 'GET #index' do describe 'GET #index' do
it 'requires admin privileges' do it 'requires organizer privileges' do
get :index get :index
expect(response).to redirect_to(send(success_path)) expect(response).to redirect_to(send(path))
if message
expect(flash[:alert]).to match(/#{message}/)
end
end end
end end
describe 'GET #new' do describe 'GET #new' do
it 'requires admin privileges' do it 'requires organizer privileges' do
get :new get :new
expect(response).to redirect_to(send(success_path)) expect(response).to redirect_to(send(path))
if message
expect(flash[:alert]).to match(/#{message}/)
end
end end
end end
describe 'POST #create' do describe 'POST #create' do
it 'requires admin privileges' do it 'requires organizer privileges' do
post :create, conference: attributes_for(:conference, post :create, conference: attributes_for(:conference,
short_title: 'ExCon') short_title: 'ExCon')
expect(response).to redirect_to(send(success_path)) expect(response).to redirect_to(send(path))
if message
expect(flash[:alert]).to match(/#{message}/)
end
end end
end end
describe 'PATCH #update' do describe 'PATCH #update' do
it 'requires admin privileges' do it 'requires organizer privileges' do
patch :update, id: conference.short_title, patch :update, id: conference.short_title,
conference: attributes_for(:conference, conference: attributes_for(:conference,
short_title: 'ExCon') short_title: 'ExCon')
expect(response).to redirect_to(send(success_path)) expect(response).to redirect_to(send(path))
if message
expect(flash[:alert]).to match(/#{message}/)
end
end end
end end
end end
@ -278,7 +281,7 @@ describe Admin::ConferenceController do
sign_in(participant) sign_in(participant)
end end
it_behaves_like 'access as participant or guest', :root_path it_behaves_like 'access as participant or guest', :root_path, 'You are not authorized to access this page.'
end end

View file

@ -1,18 +1,18 @@
require 'spec_helper' require 'spec_helper'
describe Admin::UsersController do describe Admin::UsersController do
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_conference_1_role ) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let(:admin) { create(:admin) } let(:organizer) { create(:organizer_conference_1) }
let(:user) { create(:user) } let(:user) { create(:user) }
before(:each) do before(:each) do
sign_in(admin) sign_in(organizer)
end end
describe 'GET #index' do describe 'GET #index' do
it 'populates an array of users' do it 'populates an array of users' do
user1 = create(:user, email: 'gopesh.7500@gmail.com') user1 = create(:user, email: 'gopesh.7500@gmail.com')
user2 = create(:user, email: 'gopesh_750@gmail.com') user2 = create(:user, email: 'gopesh_750@gmail.com')
get :index get :index
expect(assigns(:users)).to match_array([user, admin, user1, user2]) expect(assigns(:users)).to match_array([user, organizer, user1, user2])
end end
it 'renders index template' do it 'renders index template' do
get :index get :index
@ -31,7 +31,7 @@ describe Admin::UsersController do
:user, email: 'example@incoherent.de', id: user.id).email). :user, email: 'example@incoherent.de', id: user.id).email).
to eq('example@incoherent.de') to eq('example@incoherent.de')
end end
it "redirects to the updated user" do it 'redirects to the updated user' do
patch :update, id: user.id patch :update, id: user.id
expect(response).to redirect_to admin_users_path expect(response).to redirect_to admin_users_path
end end

View file

@ -1,16 +1,18 @@
FactoryGirl.define do FactoryGirl.define do
factory :role do factory :role do
factory :admin_role do
name 'Admin'
end
factory :organizer_role do factory :organizer_role do
name 'Organizer' name 'organizer'
end end
factory :participant_role do factory :participant_role do
name 'Participant' name 'Participant'
end end
factory :organizer_conference_1_role do
name 'organizer'
resource_type 'Conference'
resource_id 1
end
end end
end end

View file

@ -19,12 +19,12 @@ FactoryGirl.define do
after(:create) { |user| user.role_ids = create(:participant_role).id } after(:create) { |user| user.role_ids = create(:participant_role).id }
end end
factory :admin do factory :organizer_conference_1 do
after(:create) { |user| user.role_ids = create(:admin_role).id } after(:create) { |user| user.role_ids = create(:organizer_conference_1_role).id }
end end
factory :organizer do factory :admin do
after(:create) { |user| user.role_ids = create(:organizer_role).id } is_admin true
end end
end end
end end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Campaign do feature Campaign do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'add and update campaign' do |user| shared_examples 'add and update campaign' do |user|
scenario 'adds and update a campaign', feature: true, js: true do scenario 'adds and update a campaign', feature: true, js: true do
@ -52,8 +51,7 @@ feature Campaign do
end end
end end
describe 'admin' do describe 'organizer' do
it_behaves_like 'add and update campaign', :admin it_behaves_like 'add and update campaign', :organizer_conference_1
it_behaves_like 'add and update campaign', :organizer
end end
end end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'add and update cfp' do |user| shared_examples 'add and update cfp' do |user|
scenario 'adds a new cfp', feature: true, js: true do scenario 'adds a new cfp', feature: true, js: true do
@ -87,8 +86,7 @@ feature Conference do
end end
end end
describe 'admin' do describe 'organizer' do
it_behaves_like 'add and update cfp', :admin it_behaves_like 'add and update cfp', :organizer_conference_1
it_behaves_like 'add and update cfp', :organizer
end end
end end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'add and update conference' do |user| shared_examples 'add and update conference' do |user|
scenario 'adds a new conference', feature: true, js: true do scenario 'adds a new conference', feature: true, js: true do
@ -37,7 +36,7 @@ feature Conference do
scenario 'update conference', feature: true, js: true do scenario 'update conference', feature: true, js: true do
conference = create(:conference) conference = create(:conference)
expected_count = Conference.count expected_count = Conference.count
sign_in create(user) sign_in create(:organizer_conference_1_role)
visit edit_admin_conference_path(conference.short_title) visit edit_admin_conference_path(conference.short_title)
fill_in 'conference_title', with: 'New Con' fill_in 'conference_title', with: 'New Con'
@ -56,12 +55,7 @@ feature Conference do
end end
end end
describe 'admin' do describe 'organizer' do
it_behaves_like 'add and update conference', :admin it_behaves_like 'add and update conference', :admin
end end
describe 'organizer' do
it_behaves_like 'add and update conference', :organizer
end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature DifficultyLevel do feature DifficultyLevel do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'difficulty levels' do |user| shared_examples 'difficulty levels' do |user|
scenario 'adds and updates difficulty level', feature: true, js: true do scenario 'adds and updates difficulty level', feature: true, js: true do
@ -50,11 +49,7 @@ feature DifficultyLevel do
end end
end end
describe 'admin' do
it_behaves_like 'difficulty levels', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'difficulty levels', :organizer it_behaves_like 'difficulty levels', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Event do feature Event do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'email settings' do |user| shared_examples 'email settings' do |user|
scenario 'updates email settings', scenario 'updates email settings',
@ -91,11 +90,7 @@ feature Event do
end end
end end
describe 'admin' do
it_behaves_like 'email settings', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'email settings', :organizer it_behaves_like 'email settings', :organizer_conference_1
end end
end end

View file

@ -2,15 +2,14 @@ require 'spec_helper'
feature EventType do feature EventType do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'event types' do |user| shared_examples 'event types' do |user|
scenario 'adds and updates event type', feature: true, js: true do scenario 'adds and updates event type', feature: true, js: true do
conference = create(:conference) conference = create(:conference)
sign_in create(user) sign_in create(user)
visit admin_conference_eventtypes_path( visit admin_conference_event_types_path(
conference_id: conference.short_title) conference_id: conference.short_title)
expect(page.all('div.nested-fields').count == 2).to be true expect(page.all('div.nested-fields').count == 2).to be true
@ -55,11 +54,7 @@ feature EventType do
end end
end end
describe 'admin' do
it_behaves_like 'event types', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'event types', :organizer it_behaves_like 'event types', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Lodging do feature Lodging do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'lodgings' do |user| shared_examples 'lodgings' do |user|
scenario 'adds and updates lodgings', feature: true, js: true do scenario 'adds and updates lodgings', feature: true, js: true do
@ -56,11 +55,7 @@ feature Lodging do
end end
end end
describe 'admin' do
it_behaves_like 'lodgings', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'lodgings', :organizer it_behaves_like 'lodgings', :organizer_conference_1
end end
end end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature Openid do feature Openid do
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_role) }
shared_examples 'sign in with openid' do shared_examples 'sign in with openid' do

View file

@ -2,16 +2,15 @@ require 'spec_helper'
feature Event do feature Event do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'proposal workflow' do shared_examples 'proposal workflow' do
scenario 'submitts a proposal, accepts and confirms', scenario 'submitts a proposal, accepts and confirms',
feature: true, js: true do feature: true, js: true do
admin = create(:admin, email: 'admin@example.com') organizer = create(:organizer_conference_1, email: 'admin@example.com')
participant = create(:participant, email: 'participant@example.com', biography: "") participant = create(:participant, email: 'participant@example.com')
expected_count = Event.count + 1 expected_count = Event.count + 1
conference = create(:conference) conference = create(:conference)
@ -49,7 +48,7 @@ feature Event do
expect(page.has_content?('Example Proposal')).to be true expect(page.has_content?('Example Proposal')).to be true
sign_out sign_out
sign_in admin sign_in organizer
# Reject proposal # Reject proposal
visit admin_conference_events_path(conference.short_title) visit admin_conference_events_path(conference.short_title)

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Room do feature Room do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'rooms' do |user| shared_examples 'rooms' do |user|
scenario 'adds and updates rooms', feature: true, js: true do scenario 'adds and updates rooms', feature: true, js: true do
@ -43,11 +42,7 @@ feature Room do
end end
end end
describe 'admin' do
it_behaves_like 'rooms', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'rooms', :organizer it_behaves_like 'rooms', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Sponsor do feature Sponsor do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'sponsors' do |user| shared_examples 'sponsors' do |user|
scenario 'adds and updates sponsors', feature: true, js: true do scenario 'adds and updates sponsors', feature: true, js: true do
@ -69,11 +68,7 @@ feature Sponsor do
end end
end end
describe 'admin' do
it_behaves_like 'sponsors', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'sponsors', :organizer it_behaves_like 'sponsors', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature SponsorshipLevel do feature SponsorshipLevel do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'sponsorship levels' do |user| shared_examples 'sponsorship levels' do |user|
scenario 'adds and updates sponsorship level', feature: true, js: true do scenario 'adds and updates sponsorship level', feature: true, js: true do
@ -36,11 +35,7 @@ feature SponsorshipLevel do
end end
end end
describe 'admin' do
it_behaves_like 'sponsorship levels', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'sponsorship levels', :organizer it_behaves_like 'sponsorship levels', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature SupporterLevel do feature SupporterLevel do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'supporter levels' do |user| shared_examples 'supporter levels' do |user|
scenario 'adds and updates supporter level', feature: true, js: true do scenario 'adds and updates supporter level', feature: true, js: true do
@ -43,11 +42,7 @@ feature SupporterLevel do
end end
end end
describe 'admin' do
it_behaves_like 'supporter levels', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'supporter levels', :organizer it_behaves_like 'supporter levels', :organizer_conference_1
end end
end end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Track do feature Track do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'tracks' do |user| shared_examples 'tracks' do |user|
scenario 'adds and updates tracks', feature: true, js: true do scenario 'adds and updates tracks', feature: true, js: true do
@ -50,11 +49,7 @@ feature Track do
end end
end end
describe 'admin' do
it_behaves_like 'tracks', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'tracks', :organizer it_behaves_like 'tracks', :organizer_conference_1
end end
end end

View file

@ -1,14 +1,13 @@
require 'spec_helper' require 'spec_helper'
feature User do feature User do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_role) }
let(:admin) { create(:admin) } let(:organizer) { create(:organizer) }
shared_examples 'admin ability' do shared_examples 'organizer ability' do |_user|
scenario 'deletes a user', feature: true, js: true do scenario 'deletes a user', feature: true, js: true do
sign_in(admin) sign_in(organizer)
visit admin_users_path visit admin_users_path
expected_count = User.count - 1 expected_count = User.count - 1
page.all('btn btn-primary btn-danger') do page.all('btn btn-primary btn-danger') do
@ -22,7 +21,7 @@ feature User do
end end
scenario 'can modify roles', feature: true, js: true do scenario 'can modify roles', feature: true, js: true do
@user = create(:user) @user = create(:user)
sign_in(admin) sign_in(organizer)
visit admin_users_path visit admin_users_path
find("#user-modify-role-#{@user.id}").click find("#user-modify-role-#{@user.id}").click
if find("#user-role-selection-#{@user.id}").visible? if find("#user-role-selection-#{@user.id}").visible?
@ -36,7 +35,7 @@ feature User do
end end
end end
describe 'admin' do describe 'organizer' do
it_behaves_like 'admin ability', :admin it_behaves_like 'organizer ability', :organizer
end end
end end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_conference_1_role) }
shared_examples 'venue' do |user| shared_examples 'venue' do |user|
scenario 'adds and updates venue' do scenario 'adds and updates venue' do
@ -59,12 +58,8 @@ feature Conference do
end end
end end
describe 'admin' do
it_behaves_like 'venue', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'venue', :organizer it_behaves_like 'venue', :organizer_conference_1
end end
end end

View file

@ -2,15 +2,14 @@ require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
let(:admin) { create(:admin) } let(:organizer) { create(:organizer_conference_1) }
let(:conference) { create(:conference) } let(:conference) { create(:conference) }
shared_examples 'volunteer' do shared_examples 'volunteer' do
scenario 'adds and updates vdays', feature: true, js: true do scenario 'adds and updates vdays', feature: true, js: true do
sign_in(admin) sign_in(organizer)
visit admin_conference_volunteers_info_path( visit admin_conference_volunteers_info_path(
conference_id: conference.short_title) conference_id: conference.short_title)
check('Enable Volunteering') check('Enable Volunteering')
@ -54,7 +53,7 @@ feature Conference do
end end
scenario 'adds and updates vpositions', feature: true, js: true do scenario 'adds and updates vpositions', feature: true, js: true do
sign_in(admin) sign_in(organizer)
visit admin_conference_volunteers_info_path( visit admin_conference_volunteers_info_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -119,10 +118,6 @@ feature Conference do
end end
end end
describe 'admin' do
it_behaves_like 'volunteer', :admin
end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'volunteer', :organizer it_behaves_like 'volunteer', :organizer
end end

View file

@ -1,26 +1,67 @@
require 'spec_helper' require 'spec_helper'
require "cancan/matchers" require 'cancan/matchers'
describe "User" do describe 'User' do
describe "abilities" do describe 'Abilities' do
subject(:ability){ Ability.new(user) } subject(:ability){ Ability.new(user) }
let(:user){ nil } let(:user){ nil }
let(:conference_not_public) { create(:conference, make_conference_public: false) }
let(:conference_public) { create(:conference, make_conference_public: true) }
let(:event_confirmed) { create(:event, state: 'confirmed') }
let(:someevent) { create(:event) }
context "when is an admin" do context 'when is a guest' do # Test abilities for guest users
let!(:user) { create(:admin) }
it{ should be_able_to(:manage, Event.new) } it{ should be_able_to(:show, conference_public)}
it{ should_not be_able_to(:show, conference_not_public)}
it{ should be_able_to(:show, event_confirmed)}
it{ should_not be_able_to(:show, someevent)}
it{ should be_able_to(:index, :schedule)}
it{ should_not be_able_to(:create, Event)}
it{ should_not be_able_to(:manage, Event)}
it{ should_not be_able_to(:manage, Conference)}
it{ should_not be_able_to(:manage, :any)}
end end
context "when is an participant" do context 'when is a Signed In User' do # Test abilities for signed in users (without any role)
let(:user) { build(:participant) } let(:user) { create(:participant) }
let(:someuser) { create(:participant) }
let(:registration1) { create(:registration, conference: conference_public, user: user) }
let(:registration2) { create(:registration, conference: conference_not_public, user: someuser) }
it{ should_not be_able_to(:manage, Event.new) } it{ should be_able_to(:create, Event) } # Can create a new proposal
it{ should be_able_to(:create, Event.new) } it{ should be_able_to(:index, Event) } # Can access proposal index page
it{ should be_able_to(:read, Event.new) } it{ should_not be_able_to(:manage, Event.new) } # Cannot manage events that are not theirs
it{ should be_able_to(:show, event_confirmed) } # Can only view confirmed events
it{ should_not be_able_to(:show, someevent) }
# Can register for a conference
it{ should be_able_to(:register, registration1) }
it{ should be_able_to(:update, registration1) }
it{ should be_able_to(:unregister, registration1) }
# Cannot change the registration of other people
it{ should_not be_able_to(:register, registration2) }
it{ should_not be_able_to(:update, registration2) }
it{ should_not be_able_to(:unregister, registration2) }
# Can see the conference splash page only if conference is public
it{ should be_able_to(:show, conference_public)}
it{ should_not be_able_to(:show, conference_not_public)}
# Cannot manage a conference
it{ should_not be_able_to(:manage, conference_public) }
end end
context "when is an event owner" do context '#is_admin?' do
let(:user) { create(:admin) }
it{ should be_able_to(:manage, User) }
end
context 'signed in users can manage their events' do
let(:user) { create(:participant) } let(:user) { create(:participant) }
let(:user2) { create(:participant) } let(:user2) { create(:participant) }
let(:myevent) { create(:event, users: [user]) } let(:myevent) { create(:event, users: [user]) }
@ -29,11 +70,47 @@ describe "User" do
# Users are able to update and destroy their own events # Users are able to update and destroy their own events
it{ should be_able_to(:update, myevent) } it{ should be_able_to(:update, myevent) }
it{ should be_able_to(:destroy, myevent) } it{ should be_able_to(:destroy, myevent) }
it{ should be_able_to(:manage, myevent) }
# Users are not able to update and destroy other users events # Users are not able to update and destroy other users events
it{ should_not be_able_to(:update, someevent) } it{ should_not be_able_to(:update, someevent) }
it{ should_not be_able_to(:destroy, someevent) } it{ should_not be_able_to(:destroy, someevent) }
end end
context 'when is an organizer' do
let!(:conference1) { create(:conference) }
let!(:conference2) { create(:conference) }
let(:role) { create(:role, name: 'organizer', resource: conference1) }
let(:user) { create(:user, role_ids: role.id) }
let(:someuser) { create(:user) }
let(:registration1) { create(:registration, user: someuser, conference_id: conference1.id) }
it{ should be_able_to(:manage, conference1) }
it{ should_not be_able_to(:manage, conference2) }
it{ should be_able_to(:manage, registration1) }
it{ should be_able_to(:create, Registration) }
end
context 'when is part of cfp' do
let!(:conference1) { create(:conference) }
let!(:conference2) { create(:conference) }
let(:role) { create(:role, name: 'cfp', resource: conference1) }
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) }
it{ should_not be_able_to(:manage, conference1) }
it{ should_not be_able_to(:manage, conference2) }
it{ should be_able_to(:index, conference1) }
it{ should be_able_to(:show, conference1) }
it{ should be_able_to(:manage, event) }
it{ should_not be_able_to(:manage, someevent) }
it{ should be_able_to(:manage, cfp) }
it{ should be_able_to(:manage, create(:event_type, conference: conference1)) }
# it{ should_not be_able_to(:create, Registration) }
end
end end
end end

View file

@ -15,7 +15,8 @@ describe Campaign do
describe '#url_parameters' do describe '#url_parameters' do
it 'returns the parameters in the correct format' do it 'returns the parameters in the correct format' do
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') utm_term: 'opensource', utm_content: 'content',
utm_campaign: '20percent')
campaign.conference = create(:conference) campaign.conference = create(:conference)
result = '?utm_source=google+&utm_medium=advertisement&utm_term=opensource&utm_content=content&utm_campaign=20percent' result = '?utm_source=google+&utm_medium=advertisement&utm_term=opensource&utm_content=content&utm_campaign=20percent'
@ -32,17 +33,19 @@ describe Campaign do
describe '#visits' do describe '#visits' do
it 'returns one if there is one visit' do it 'returns one if there is one visit' do
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') utm_term: 'opensource', utm_content: 'content',
utm_campaign: '20percent')
campaign.conference = build(:conference) campaign.conference = build(:conference)
create(:visit, utm_source: 'google+', utm_medium: 'advertisement', create(:visit, utm_source: 'google+', utm_medium: 'advertisement', utm_term: 'opensource',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent', started_at: Time.now) utm_content: 'content', utm_campaign: '20percent', started_at: Time.now)
expect(campaign.visits_count).to eq(1) expect(campaign.visits_count).to eq(1)
end end
it 'returns zero if there are no visits' do it 'returns zero if there are no visits' do
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') utm_term: 'opensource', utm_content: 'content',
utm_campaign: '20percent')
campaign.conference = create(:conference) campaign.conference = create(:conference)
expect(campaign.visits_count).to eq(0) expect(campaign.visits_count).to eq(0)
@ -52,7 +55,8 @@ describe Campaign do
describe '#registrations' do describe '#registrations' do
it 'returns zero if there are no registration' do it 'returns zero if there are no registration' do
campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement', campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') utm_term: 'opensource', utm_content: 'content',
utm_campaign: '20percent')
campaign.conference = build(:conference) campaign.conference = build(:conference)
expect(campaign.registrations_count).to eq(0) expect(campaign.registrations_count).to eq(0)
@ -62,7 +66,8 @@ describe Campaign do
describe '#submissions' do describe '#submissions' do
it 'returns zero if there are no submissions' do it 'returns zero if there are no submissions' do
campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement', campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') utm_term: 'opensource', utm_content: 'content',
utm_campaign: '20percent')
campaign.conference = build(:conference) campaign.conference = build(:conference)
expect(campaign.submissions_count).to eq(0) expect(campaign.submissions_count).to eq(0)

View file

@ -274,9 +274,8 @@ describe Conference do
describe '#get_top_submitter' do describe '#get_top_submitter' do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_role) }
it 'calculates correct hash with top submitters' do it 'calculates correct hash with top submitters' do
event = create(:event, conference: subject) event = create(:event, conference: subject)
@ -897,9 +896,8 @@ describe Conference do
describe 'self#event_distribution' do describe 'self#event_distribution' do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_role) }
it 'self#event_distribution calculates correct values with user' do it 'self#event_distribution calculates correct values with user' do
create(:user, last_sign_in_at: Date.today - 3.months) # active create(:user, last_sign_in_at: Date.today - 3.months) # active
@ -1426,9 +1424,8 @@ describe Conference do
describe '#user_registered?' do describe '#user_registered?' do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_role) { create(:organizer_role) }
let(:user) { create(:user) } let(:user) { create(:user) }

View file

@ -3,53 +3,49 @@ require 'spec_helper'
describe User do describe User do
# It is necessary to use bang version of let to build roles before user # It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:organizer_conference_1_role ) { create(:organizer_conference_1_role ) }
let!(:admin) { create(:user) } let!(:organizer) { create(:organizer_conference_1 ) }
it 'returns the correct role' do it 'returns the correct role' do
participant = create(:user, email: 'participant@example.de') participant = create(:user, email: 'participant@example.de')
expect(admin.roles.first).to eq(admin_role) expect(organizer.roles.first).to eq(organizer_conference_1_role)
expect(participant.roles.first).to eq(participant_role) expect(participant.roles.first).to eq(organizer_conference_1_role)
end end
it 'returns the correct roles' do it 'returns the correct roles' do
roles = [organizer_role.id, participant_role.id, admin_role.id] roles = [participant_role.id, organizer_conference_1_role.id]
user_with_all_roles = create(:user, email: 'participant@example.de') user_with_all_roles = create(:user, email: 'participant@example.de')
user_with_all_roles.role_ids = roles user_with_all_roles.role_ids = roles
user_with_all_roles.save user_with_all_roles.save
expect(user_with_all_roles.roles.length).to eq(3) expect(user_with_all_roles.roles.length).to eq(2)
expect(user_with_all_roles.roles[0]).to eq(participant_role) expect(user_with_all_roles.roles[0]).to eq(participant_role)
expect(user_with_all_roles.roles[1]).to eq(organizer_role) expect(user_with_all_roles.roles[1]).to eq(organizer_conference_1_role )
expect(user_with_all_roles.roles[2]).to eq(admin_role)
end end
describe '#role?' do describe '#role?' do
shared_examples '#role?' do |user, role, expected| shared_examples '#role?' do |user, role, expected|
it "returns #{expected} for #{role}" do it "returns #{expected} for #{role}" do
user_obj = create(user, email: 'e@example.com') user_obj = create(user, email: 'e@example.com')
expect(user_obj.role?(role)).to be expected expect(user_obj.has_role?(role)).to be expected
expect(user_obj.role?(role.downcase)).to be expected expect(user_obj.has_role?(role.downcase)).to be expected
expect(user_obj.role?(role.upcase)).to be expected expect(user_obj.has_role?(role.upcase)).to be expected
expect(user_obj.role?(role.downcase.capitalize)).to be expected expect(user_obj.has_role?(role.downcase.capitalize)).to be expected
end end
end end
context 'admin' do context 'organizer' do
it_behaves_like '#role?', :admin, 'orgAnizer', false it_behaves_like '#role?', :organizer_conference_1_role, 'oRganIzeR', true
it_behaves_like '#role?', :admin, 'adMin', true it_behaves_like '#role?', :organizer_conference_1_role, 'partiCipant', false
it_behaves_like '#role?', :admin, 'partiCipant', false
it 'assigns first user admin role' do it 'assigns first user organizer role' do
expect(admin.role?('Admin')).to be true expect(organizer.has_role?('organizer', Conference.first)).to be true
expect(admin.role_ids).to match_array([admin_role.id]) expect(organizer.role_ids).to match_array([organizer_conference_1_role.id])
end end
end end
context 'participant' do context 'participant' do
it_behaves_like '#role?', :participant, 'orgAnizer', false
it_behaves_like '#role?', :participant, 'adMin', false it_behaves_like '#role?', :participant, 'adMin', false
it_behaves_like '#role?', :participant, 'partiCipant', true it_behaves_like '#role?', :participant, 'partiCipant', true
@ -58,11 +54,5 @@ describe User do
expect(participant.role_ids).to match_array([participant_role.id]) expect(participant.role_ids).to match_array([participant_role.id])
end end
end end
context 'organizer' do
it_behaves_like '#role?', :organizer, 'orgAnizer', true
it_behaves_like '#role?', :organizer, 'adMin', false
it_behaves_like '#role?', :organizer, 'partiCipant', false
end
end end
end end

View file

@ -3,10 +3,10 @@ require 'spec_helper'
describe 'admin/conference/edit' do describe 'admin/conference/edit' do
it 'renders conference details which are editable' do it 'renders conference details which are editable' do
@conference = create(:conference, title: 'OpenSUSE') @conference = create(:conference, title: 'openSUSE')
assign :conference, @conference assign :conference, @conference
render template: 'admin/conference/edit.html.haml' render template: 'admin/conference/edit.html.haml'
expect(rendered).to include('OpenSUSE') expect(rendered).to include('openSUSE')
expect(rendered).to include("#{@conference.contact_email}") expect(rendered).to include("#{@conference.contact_email}")
end end
end end

View file

@ -2,9 +2,9 @@ require 'spec_helper'
describe 'admin/conference/index' do describe 'admin/conference/index' do
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, [create(:conference, title: 'openSUSE'), create(:conference)])
render render
expect(rendered).to include('OpenSUSE') expect(rendered).to include('openSUSE')
expect(rendered).to include("The dog and pony show") expect(rendered).to include('The dog and pony show')
end end
end end

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'admin/conference/show' do describe 'admin/conference/show' do
it 'renders conference dashboard' do it 'renders conference dashboard' do
conference = create(:conference, title: 'OpenSUSE') conference = create(:conference, title: 'openSUSE')
assign :conference, conference assign :conference, conference
assign :conference_progress, conference.get_status assign :conference_progress, conference.get_status
render render

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'admin/eventtypes/index' do describe 'admin/event_types/index' do
it 'renders event types' do it 'renders event types' do
@event_type = create(:event_type) @event_type = create(:event_type)

View file

@ -1,5 +1,5 @@
require 'spec_helper' require 'spec_helper'
describe "admin/volunteers/show" do describe 'admin/volunteers/show' do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -10,8 +10,8 @@ describe 'conference/show.html.haml' do
sponsor_email: 'example@example.com', sponsor_email: 'example@example.com',
facebook_url: 'http://www.fbexample.com', facebook_url: 'http://www.fbexample.com',
google_url: 'http://www.google-example.com', google_url: 'http://www.google-example.com',
instagram_url: "http://instagram.com", instagram_url: 'http://instagram.com',
twitter_url: "http://twitter.com", twitter_url: 'http://twitter.com',
include_registrations_in_splash: true, include_registrations_in_splash: true,
include_program_in_splash: true, include_program_in_splash: true,
include_sponsors_in_splash: true, include_sponsors_in_splash: true,
@ -65,8 +65,8 @@ describe 'conference/show.html.haml' do
expect(view).to render_template('conference/_social_media') expect(view).to render_template('conference/_social_media')
expect(view.content_for(:splash)).to include('http://www.fbexample.com') expect(view.content_for(:splash)).to include('http://www.fbexample.com')
expect(view.content_for(:splash)).to include('http://www.google-example.com') expect(view.content_for(:splash)).to include('http://www.google-example.com')
expect(view.content_for(:splash)).to include("http://instagram.com") expect(view.content_for(:splash)).to include('http://instagram.com')
expect(view.content_for(:splash)).to include("http://twitter.com") expect(view.content_for(:splash)).to include('http://twitter.com')
end end
it 'renders location partial' do it 'renders location partial' do