Mechanical standard.rb changes

This commit is contained in:
Petko Bordjukov 2019-04-28 21:10:54 +03:00
parent 895bf8a5f3
commit e20861689f
102 changed files with 731 additions and 755 deletions

14
Capfile
View File

@ -1,8 +1,8 @@
# Load DSL and set up stages # Load DSL and set up stages
require 'capistrano/setup' require "capistrano/setup"
# Include default deployment tasks # Include default deployment tasks
require 'capistrano/deploy' require "capistrano/deploy"
require "capistrano/scm/git" require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git install_plugin Capistrano::SCM::Git
@ -21,13 +21,13 @@ install_plugin Capistrano::SCM::Git
# require 'capistrano/rvm' # require 'capistrano/rvm'
# require 'capistrano/rbenv' # require 'capistrano/rbenv'
# require 'capistrano/chruby' # require 'capistrano/chruby'
require 'capistrano/bundler' require "capistrano/bundler"
require 'capistrano/rails/assets' require "capistrano/rails/assets"
require 'capistrano/rails/migrations' require "capistrano/rails/migrations"
require 'capistrano/puma' require "capistrano/puma"
# require 'capistrano/puma/nginx' # if you want to upload a nginx site template # require 'capistrano/puma/nginx' # if you want to upload a nginx site template
# require 'capistrano/passenger' # require 'capistrano/passenger'
# require 'capistrano/rvm' # require 'capistrano/rvm'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined # Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

118
Gemfile
View File

@ -1,98 +1,98 @@
source 'https://rubygems.org' source "https://rubygems.org"
gem 'rails', '~> 5.2.0' gem "rails", "~> 5.2.0"
gem 'bootsnap' gem "bootsnap"
gem 'sqlite3' gem "sqlite3"
gem 'pg' gem "pg"
gem 'sass-rails' gem "sass-rails"
gem 'uglifier' gem "uglifier"
gem 'coffee-rails' gem "coffee-rails"
gem 'mini_racer', platforms: :ruby gem "mini_racer", platforms: :ruby
gem 'jquery-rails' gem "jquery-rails"
gem 'slim-rails' gem "slim-rails"
gem 'rails-i18n' gem "rails-i18n"
gem 'devise' gem "devise"
gem 'devise-i18n' gem "devise-i18n"
gem 'simple_form' gem "simple_form"
# Phone validation # Phone validation
gem 'phony', '~> 2.15.11' gem "phony", "~> 2.15.11"
gem 'phony_rails' gem "phony_rails"
# Picture uploads # Picture uploads
gem 'carrierwave' gem "carrierwave"
#gem 'rmagick' # gem 'rmagick'
gem "mini_magick" gem "mini_magick"
gem "refile", github: 'refile/refile', require: ['refile/rails', 'refile/simple_form'] gem "refile", github: "refile/refile", require: ["refile/rails", "refile/simple_form"]
gem "image_processing" gem "image_processing"
gem 'puma', group: :production gem "puma", group: :production
gem 'globalize' gem "globalize"
gem 'yaml_db' gem "yaml_db"
gem 'bootstrap-sass' gem "bootstrap-sass"
gem 'bootstrap-sass-extras' gem "bootstrap-sass-extras"
gem 'bootswatch-rails' gem "bootswatch-rails"
gem 'autoprefixer-rails' gem "autoprefixer-rails"
gem 'font-awesome-sass', '~> 4.6.2' gem "font-awesome-sass", "~> 4.6.2"
gem 'nested_form' gem "nested_form"
gem 'jquery-datatables-rails' gem "jquery-datatables-rails"
gem 'morrisjs-rails' gem "morrisjs-rails"
gem 'raphael-rails' gem "raphael-rails"
gem 'copy_carrierwave_file' gem "copy_carrierwave_file"
gem 'jbuilder' gem "jbuilder"
gem 'search_object' gem "search_object"
gem 'faraday' gem "faraday"
gem 'rqrcode' gem "rqrcode"
group :development do group :development do
gem 'spring' gem "spring"
gem 'spring-commands-rspec' gem "spring-commands-rspec"
gem 'guard-rspec' # Continuous testing with Guard gem "guard-rspec" # Continuous testing with Guard
gem 'rails-erd' gem "rails-erd"
gem 'pry-rails' gem "pry-rails"
# gem 'hirb' # gem 'hirb'
gem 'awesome_print' gem "awesome_print"
gem 'capistrano' gem "capistrano"
gem 'capistrano-rails' gem "capistrano-rails"
# gem 'capistrano-rvm' # gem 'capistrano-rvm'
gem 'capistrano3-puma' gem "capistrano3-puma"
gem 'better_errors' gem "better_errors"
gem 'binding_of_caller' gem "binding_of_caller"
end end
group :development, :test do group :development, :test do
gem 'rspec-rails' gem "rspec-rails"
gem 'factory_bot_rails' gem "factory_bot_rails"
gem 'faker' gem "faker"
gem 'capybara' gem "capybara"
gem 'selenium-webdriver' gem "selenium-webdriver"
gem 'byebug' gem "byebug"
gem 'simplecov' gem "simplecov"
gem 'i18n-tasks' gem "i18n-tasks"
gem 'delorean' gem "delorean"
gem 'standard' gem "standard"
end end
group :test do group :test do
gem 'database_cleaner' gem "database_cleaner"
end end

View File

@ -1,17 +1,17 @@
# More info at https://github.com/guard/guard#readme # More info at https://github.com/guard/guard#readme
guard :rspec, cmd: 'spring rspec' do guard :rspec, cmd: "spring rspec" do
watch(%r{^spec/.+_spec\.rb$}) watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' } watch("spec/spec_helper.rb") { "spec" }
watch('spec/rails_helper.rb') { 'spec' } watch("spec/rails_helper.rb") { "spec" }
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { 'spec/routing' } watch("config/routes.rb") { "spec/routing" }
watch('app/controllers/application_controller.rb') { 'spec/controllers' } watch("app/controllers/application_controller.rb") { "spec/controllers" }
# Capybara features specs # Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }

View File

@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require File.expand_path("../config/application", __FILE__)
Rails.application.load_tasks Rails.application.load_tasks

View File

@ -9,10 +9,10 @@ class ApplicationController < ActionController::Base
before_action :set_view_paths before_action :set_view_paths
# TODO: make this get the domain from the database # TODO: make this get the domain from the database
#layout Proc.new { |controller| controller.request.host } # layout Proc.new { |controller| controller.request.host }
layout 'public/application' layout "public/application"
def self.default_url_options(options={}) def self.default_url_options(options = {})
if I18n.locale != I18n.default_locale if I18n.locale != I18n.default_locale
options.merge({locale: I18n.locale}) options.merge({locale: I18n.locale})
else else
@ -24,17 +24,16 @@ class ApplicationController < ActionController::Base
def set_locale def set_locale
I18n.locale = params[:locale] || I18n.default_locale I18n.locale = params[:locale] || I18n.default_locale
if user_signed_in? and current_user.language != I18n.locale if user_signed_in? && (current_user.language != I18n.locale)
current_user.update(language: I18n.locale) current_user.update(language: I18n.locale)
end end
end end
def set_view_paths def set_view_paths
# TODO: make this get the domain from the database # TODO: make this get the domain from the database
prepend_view_path 'lib/initfest/views' if request.host =~ /openfest/ prepend_view_path "lib/initfest/views" if request.host =~ /openfest/
prepend_view_path 'lib/initfest/views' if request.host =~ /example/ prepend_view_path "lib/initfest/views" if request.host =~ /example/
prepend_view_path 'lib/initfest/views' if request.host =~ /127\.0\.0/ prepend_view_path "lib/initfest/views" if request.host =~ /127\.0\.0/
end end
protected protected

View File

@ -11,8 +11,8 @@ module CurrentConferenceAssigning
end end
def current_conference def current_conference
if not @current_conference unless @current_conference
if @conference and not @conference.new_record? if @conference && !@conference.new_record?
@current_conference = @conference @current_conference = @conference
elsif params[:conference_id].present? elsif params[:conference_id].present?
@current_conference = Conference.find(params[:conference_id]) @current_conference = Conference.find(params[:conference_id])
@ -23,8 +23,8 @@ module CurrentConferenceAssigning
end end
def require_current_conference! def require_current_conference!
if not current_conference? unless current_conference?
raise ActionController::RoutingError.new('Not Found') raise ActionController::RoutingError.new("Not Found")
end end
end end
end end

View File

@ -1,14 +1,14 @@
require 'active_support/concern' require "active_support/concern"
module PublicApiExposing module PublicApiExposing
extend ActiveSupport::Concern extend ActiveSupport::Concern
def set_access_control_headers def set_access_control_headers
if request.format.json? if request.format.json?
response.headers['Access-Control-Allow-Origin'] = '*' response.headers["Access-Control-Allow-Origin"] = "*"
end end
end end
included do included do
before_action :set_access_control_headers before_action :set_access_control_headers
end end

View File

@ -6,9 +6,9 @@ class ConfirmationsController < Devise::ConfirmationsController
if resource.errors.empty? if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_flashing_format? set_flash_message(:notice, :confirmed) if is_flashing_format?
sign_in(resource_name, resource) sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
else else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
end end
end end
end end

View File

@ -2,10 +2,10 @@ module Management
class ConferencesController < ManagementController class ConferencesController < ManagementController
def new def new
@conference = Conference.new @conference = Conference.new
@conference.event_types.build(name: 'Event type 1') @conference.event_types.build(name: "Event type 1")
@conference.tracks.build(name: 'Track 1') @conference.tracks.build(name: "Track 1")
@conference.halls.build(name: 'Hall 1') @conference.halls.build(name: "Hall 1")
@conference.volunteer_teams.build(name: 'Volunteer Team 1') @conference.volunteer_teams.build(name: "Volunteer Team 1")
end end
def create def create
@ -49,13 +49,13 @@ module Management
begin begin
if @conference.update_vote_data! if @conference.update_vote_data!
flash[:notice] = t('.vote_data_successfully_updated') flash[:notice] = t(".vote_data_successfully_updated")
else else
flash[:alert] = t('.error_during_vote_data_save') flash[:alert] = t(".error_during_vote_data_save")
end end
redirect_back fallback_location: [:management, @conference] redirect_back fallback_location: [:management, @conference]
rescue StandardError => e rescue => e
flash[:alert] = t('.error_during_connection_with_voting_endpoint', error: e.message) flash[:alert] = t(".error_during_connection_with_voting_endpoint", error: e.message)
render :vote_results render :vote_results
end end
end end
@ -75,9 +75,9 @@ module Management
:title, :email, :start_date, :end_date, :description, :host_name, :title, :email, :start_date, :end_date, :description, :host_name,
:planned_cfp_end_date, :vote_data_endpoint, :planned_cfp_end_date, :vote_data_endpoint,
event_types_attributes: [:id, :name, :description, :maximum_length, event_types_attributes: [:id, :name, :description, :maximum_length,
:minimum_length, :_destroy], :minimum_length, :_destroy,],
tracks_attributes: [:id, :name, :color, :css_class, :description, tracks_attributes: [:id, :name, :color, :css_class, :description,
:css_style, :foreground_color, :_destroy], :css_style, :foreground_color, :_destroy,],
halls_attributes: [:id, :name, :_destroy], halls_attributes: [:id, :name, :_destroy],
volunteer_teams_attributes: [:id, :name, :description, :color, :_destroy] volunteer_teams_attributes: [:id, :name, :description, :color, :_destroy]
) )

View File

@ -22,10 +22,10 @@ module Management
@event = @conference.events.find(params[:id]) @event = @conference.events.find(params[:id])
if @event.update(event_params) if @event.update(event_params)
flash[:notice] = t('.event_successfully_updated') flash[:notice] = t(".event_successfully_updated")
redirect_to [:management, @conference, @event] redirect_to [:management, @conference, @event]
else else
render action: 'edit' render action: "edit"
end end
end end
@ -51,22 +51,22 @@ module Management
def event_params def event_params
params.require(:event).permit( params.require(:event).permit(
:title, :title,
:subtitle, :subtitle,
:length, :length,
:language, :language,
:abstract, :abstract,
:description, :description,
:notes, :notes,
:track_id, :track_id,
:event_type_id, :event_type_id,
participations_attributes: [ participations_attributes: [
:id, :id,
:participant_id, :participant_id,
:approved, :approved,
:_destroy :_destroy,
] ]
) )
end end
end end
end end

View File

@ -1,9 +1,9 @@
require 'csv' require "csv"
module Management module Management
class ManagementController < ::ApplicationController class ManagementController < ::ApplicationController
before_action :authenticate_user!, :authorize_user! before_action :authenticate_user!, :authorize_user!
layout 'management' layout "management"
private private

View File

@ -18,7 +18,7 @@ module Management
@profile = find_profile @profile = find_profile
@user = @profile.user @user = @profile.user
if not @profile unless @profile
flash[:error] = "No profile, needs to be created" flash[:error] = "No profile, needs to be created"
redirect_to action: :edit redirect_to action: :edit
end end
@ -36,7 +36,7 @@ module Management
@profile = @user.build_personal_profile(@conference, profile_params) @profile = @user.build_personal_profile(@conference, profile_params)
if @profile.save if @profile.save
flash[:notice] = t('.successfully_created') flash[:notice] = t(".successfully_created")
redirect_to management_conference_personal_profile_path(@profile, conference_id: @conference.id) redirect_to management_conference_personal_profile_path(@profile, conference_id: @conference.id)
else else
render action: :new render action: :new
@ -56,7 +56,7 @@ module Management
if @profile.update_attributes(profile_params) if @profile.update_attributes(profile_params)
redirect_to [:management, @conference, @profile] redirect_to [:management, @conference, @profile]
else else
render action: 'edit' render action: "edit"
end end
end end

View File

@ -26,12 +26,13 @@ module Management
end end
private private
def volunteer_params def volunteer_params
params.require(:volunteer).permit(:name, :picture, :email, :phone, params.require(:volunteer).permit(:name, :picture, :email, :phone,
:tshirt_size, :tshirt_cut, :tshirt_size, :tshirt_cut,
:food_preferences, :previous_experience, :food_preferences, :previous_experience,
:notes, :language, :notes, :language,
volunteer_team_ids: []) volunteer_team_ids: [])
end end
end end
end end

View File

@ -2,15 +2,14 @@ class Public::ConferenceFeedbacksController < Public::ApplicationController
def index def index
@conference = current_conference @conference = current_conference
@unrated_events = @conference.events @unrated_events = @conference.events
.joins(:proposition).approved .joins(:proposition).approved
.joins('LEFT JOIN feedbacks ON feedbacks.feedback_receiving_id = events.id AND feedbacks.feedback_receiving_type = \'Event\'') .joins("LEFT JOIN feedbacks ON feedbacks.feedback_receiving_id = events.id AND feedbacks.feedback_receiving_type = 'Event'")
.where('feedbacks.session_id != ? OR feedbacks.id IS NULL', session.id).distinct .where("feedbacks.session_id != ? OR feedbacks.id IS NULL", session.id).distinct
@rated_events = @conference.events @rated_events = @conference.events
.joins(:proposition).approved .joins(:proposition).approved
.joins(:feedbacks) .joins(:feedbacks)
.where(feedbacks: {session_id: session.id}).distinct .where(feedbacks: {session_id: session.id}).distinct
end end
def new def new
@ -28,7 +27,7 @@ class Public::ConferenceFeedbacksController < Public::ApplicationController
@feedback.session_id = session.id @feedback.session_id = session.id
if @feedback.save if @feedback.save
flash[:notice] = I18n.t('public.conference_feedbacks.new.success') flash[:notice] = I18n.t("public.conference_feedbacks.new.success")
redirect_to conference_feedbacks_path redirect_to conference_feedbacks_path
else else
render :new, status: :unprocessable_entity render :new, status: :unprocessable_entity

View File

@ -5,7 +5,7 @@ class Public::EventFeedbackQrcodesController < Public::ApplicationController
respond_to do |format| respond_to do |format|
format.svg do format.svg do
render(inline: @qr.as_svg(shape_rendering: 'crispEdges', module_size: 11, fill: 'ffffff', offset: 10), render(inline: @qr.as_svg(shape_rendering: "crispEdges", module_size: 11, fill: "ffffff", offset: 10),
filename: "feedback_qr_code_#{event.id}.svg") filename: "feedback_qr_code_#{event.id}.svg")
end end
end end

View File

@ -14,7 +14,7 @@ class Public::EventFeedbacksController < Public::ApplicationController
@feedback.session_id = session.id @feedback.session_id = session.id
if @feedback.save if @feedback.save
flash[:notice] = I18n.t('public.event_feedbacks.new.success') flash[:notice] = I18n.t("public.event_feedbacks.new.success")
redirect_to conference_feedbacks_path redirect_to conference_feedbacks_path
else else
render :new, status: :unprocessable_entity render :new, status: :unprocessable_entity

View File

@ -3,7 +3,7 @@ module Public
before_action :authenticate_user! before_action :authenticate_user!
def index def index
@events = Event.joins(:conference, :proposition, :participations).where(conference: current_conference).where('propositions.proposer_id = ? OR participations.participant_id = ?', current_user.id, current_user.id) @events = Event.joins(:conference, :proposition, :participations).where(conference: current_conference).where("propositions.proposer_id = ? OR participations.participant_id = ?", current_user.id, current_user.id)
end end
def edit def edit
@ -22,7 +22,7 @@ module Public
@event.participations.build participant: current_user, approved: true @event.participations.build participant: current_user, approved: true
if @event.save if @event.save
flash[:notice] = I18n.t('views.events.event_successfully_created', event_type: @event.event_type.name.mb_chars.downcase) flash[:notice] = I18n.t("views.events.event_successfully_created", event_type: @event.event_type.name.mb_chars.downcase)
after_save_redirect after_save_redirect
else else
render action: :new render action: :new
@ -33,7 +33,7 @@ module Public
@event = Event.joins(:participations).find_by(id: params[:id], participations: {participant_id: current_user.id}) @event = Event.joins(:participations).find_by(id: params[:id], participations: {participant_id: current_user.id})
if @event.update(event_params) if @event.update(event_params)
flash[:notice] = I18n.t('views.events.event_successfully_updated', event_type: @event.event_type.name.mb_chars.downcase) flash[:notice] = I18n.t("views.events.event_successfully_updated", event_type: @event.event_type.name.mb_chars.downcase)
after_save_redirect after_save_redirect
else else
render action: :edit render action: :edit
@ -44,9 +44,9 @@ module Public
@event = current_user.events.approved.find(params[:id]) @event = current_user.events.approved.find(params[:id])
if @event.confirm! if @event.confirm!
flash[:notice] = I18n.t('views.events.successfully_confirmed', event_type: @event.event_type.name.mb_chars.downcase) flash[:notice] = I18n.t("views.events.successfully_confirmed", event_type: @event.event_type.name.mb_chars.downcase)
else else
flash[:alert] = I18n.t('views.events.error_on_confirmation', event_type: @event.event_type.name.mb_chars.downcase) flash[:alert] = I18n.t("views.events.error_on_confirmation", event_type: @event.event_type.name.mb_chars.downcase)
end end
after_save_redirect after_save_redirect

View File

@ -6,7 +6,7 @@ module Public
@profile = current_user.build_personal_profile(current_conference, profile_params) @profile = current_user.build_personal_profile(current_conference, profile_params)
if @profile.save if @profile.save
flash[:notice] = t('views.personal_profiles.successfully_created') flash[:notice] = t("views.personal_profiles.successfully_created")
redirect_to root_path redirect_to root_path
else else
render action: :new render action: :new
@ -21,10 +21,10 @@ module Public
@profile = current_user.personal_profile(current_conference) @profile = current_user.personal_profile(current_conference)
if @profile.update_attributes(profile_params) if @profile.update_attributes(profile_params)
flash[:notice] = t('views.personal_profiles.successfully_updated') flash[:notice] = t("views.personal_profiles.successfully_updated")
redirect_to root_path redirect_to root_path
else else
render action: 'edit' render action: "edit"
end end
end end

View File

@ -11,7 +11,7 @@ module Public
def create def create
@volunteer = current_conference.volunteers.build volunteer_params @volunteer = current_conference.volunteers.build volunteer_params
if @volunteer.save if @volunteer.save
flash[:notice] = I18n.t('views.volunteers.successful_application') flash[:notice] = I18n.t("views.volunteers.successful_application")
redirect_to edit_volunteer_path(@volunteer.unique_id) redirect_to edit_volunteer_path(@volunteer.unique_id)
else else
render :new, status: :unprocessable_entity render :new, status: :unprocessable_entity
@ -21,7 +21,7 @@ module Public
def update def update
@volunteer = current_conference.volunteers.find_by! unique_id: params[:id] @volunteer = current_conference.volunteers.find_by! unique_id: params[:id]
if @volunteer.update volunteer_params if @volunteer.update volunteer_params
flash[:notice] = I18n.t('views.volunteers.successful_application_edit') flash[:notice] = I18n.t("views.volunteers.successful_application_edit")
redirect_to edit_volunteer_path(@volunteer.unique_id) redirect_to edit_volunteer_path(@volunteer.unique_id)
else else
render :edit, status: :unprocessable_entity render :edit, status: :unprocessable_entity

View File

@ -12,9 +12,9 @@ module Public
@volunteership.build_proposition proposer: current_user, status: :undecided @volunteership.build_proposition proposer: current_user, status: :undecided
if @volunteership.save if @volunteership.save
flash[:notice] = I18n.t('views.volunteerships.you_successfully_applied_for', team: @volunteership.volunteer_team.name) flash[:notice] = I18n.t("views.volunteerships.you_successfully_applied_for", team: @volunteership.volunteer_team.name)
else else
flash[:error] = I18n.t('views.volunteerships.an error_occurred_while_applying') flash[:error] = I18n.t("views.volunteerships.an error_occurred_while_applying")
end end
after_save_redirect after_save_redirect
@ -24,7 +24,7 @@ module Public
@volunteership = current_user.volunteerships.find params[:id] @volunteership = current_user.volunteerships.find params[:id]
if @volunteership.destroy if @volunteership.destroy
flash[:notice] = I18n.t('views.volunteerships.you_successfully_retracted_your_application_for', team: @volunteership.volunteer_team.name) flash[:notice] = I18n.t("views.volunteerships.you_successfully_retracted_your_application_for", team: @volunteership.volunteer_team.name)
end end
redirect_to volunteerships_path redirect_to volunteerships_path

View File

@ -10,7 +10,7 @@ module ApplicationHelper
"undecided" => "default", "undecided" => "default",
"approved" => "info", "approved" => "info",
"rejected" => "danger", "rejected" => "danger",
"backup" => "warning" "backup" => "warning",
}.with_indifferent_access[status] }.with_indifferent_access[status]
end end
@ -19,7 +19,7 @@ module ApplicationHelper
"undecided" => "question", "undecided" => "question",
"approved" => "thumbs-up", "approved" => "thumbs-up",
"rejected" => "thumbs-down", "rejected" => "thumbs-down",
"backup" => "refresh" "backup" => "refresh",
}.with_indifferent_access[status] }.with_indifferent_access[status]
end end
@ -29,36 +29,36 @@ module ApplicationHelper
def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy]) def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy])
klass = record.class klass = record.class
output = '' output = ""
if actions.include? :index if actions.include? :index
output += link_to(icon(:list), [:management, conference, klass], { output += link_to(icon(:list), [:management, conference, klass], {
title: t('actions.index.button', models: klass.model_name.human(count: 2)), title: t("actions.index.button", models: klass.model_name.human(count: 2)),
class: 'btn btn-info' class: "btn btn-info",
}) })
end end
if actions.include? :show if actions.include? :show
output += link_to(icon(:eye), [:management, conference, record], { output += link_to(icon(:eye), [:management, conference, record], {
title: t('actions.view.button', model: klass.model_name.human), title: t("actions.view.button", model: klass.model_name.human),
class: 'btn btn-info' class: "btn btn-info",
}) })
end end
if actions.include? :edit if actions.include? :edit
output += link_to(icon(:edit), [:edit, :management, conference, record], { output += link_to(icon(:edit), [:edit, :management, conference, record], {
title: t('actions.edit.button', model: klass.model_name.human), title: t("actions.edit.button", model: klass.model_name.human),
class: 'btn btn-warning' class: "btn btn-warning",
}) })
end end
if actions.include? :destroy if actions.include? :destroy
output += link_to(icon(:trash), [:management, conference, record], { output += link_to(icon(:trash), [:management, conference, record], {
method: :delete, method: :delete,
data: {confirm: t('actions.are_you_sure')}, data: {confirm: t("actions.are_you_sure")},
title: t('actions.destroy.button', model: klass.model_name.human), title: t("actions.destroy.button", model: klass.model_name.human),
class: 'btn btn-danger' class: "btn btn-danger",
}) })
end end
output.html_safe output.html_safe

View File

@ -5,26 +5,26 @@ module ConferencesHelper
start_date = conference.created_at.to_date start_date = conference.created_at.to_date
end_date = Time.zone.now.to_date < conference.start_date.to_date ? Time.zone.now.to_date : conference.start_date.to_date end_date = Time.zone.now.to_date < conference.start_date.to_date ? Time.zone.now.to_date : conference.start_date.to_date
chart_data = (start_date..end_date).map do |date| chart_data = (start_date..end_date).map { |date|
{ {
created_at: date, created_at: date,
new_submissions: submissions_by_day[date].try(:first).try(:number) || 0, new_submissions: submissions_by_day[date].try(:first).try(:number) || 0,
new_confirmations: confirmed_by_day[date].try(:first).try(:number) || 0 new_confirmations: confirmed_by_day[date].try(:first).try(:number) || 0,
} }
end }
chart_data.each_with_index do |entry, index| chart_data.each_with_index do |entry, index|
entry[:all_submissions] = if index == 0 entry[:all_submissions] = if index == 0
entry[:new_submissions] entry[:new_submissions]
else else
chart_data[index - 1][:all_submissions] + entry[:new_submissions] chart_data[index - 1][:all_submissions] + entry[:new_submissions]
end end
entry[:all_confirmations] = if index == 0 entry[:all_confirmations] = if index == 0
entry[:new_confirmations] entry[:new_confirmations]
else else
chart_data[index - 1][:all_confirmations] + entry[:new_confirmations] chart_data[index - 1][:all_confirmations] + entry[:new_confirmations]
end end
end end
chart_data chart_data
end end

View File

@ -1,16 +1,16 @@
module EventsHelper module EventsHelper
def links_to_event_participants_for(event) def links_to_event_participants_for(event)
event.participants_with_personal_profiles.map do |participant| event.participants_with_personal_profiles.map { |participant|
if participant.has_personal_profile? if participant.has_personal_profile?
link_to icon(:user, participant.name), link_to icon(:user, participant.name),
management_conference_personal_profile_path(participant.personal_profile_id, conference_id: event.conference.id) management_conference_personal_profile_path(participant.personal_profile_id, conference_id: event.conference.id)
else else
link_to icon('user-plus', participant.personal_email), link_to icon("user-plus", participant.personal_email),
new_management_conference_personal_profile_path(conference_id: event.conference.id, new_management_conference_personal_profile_path(conference_id: event.conference.id,
user_id: participant.id), user_id: participant.id),
title: t('management.events.event.create_profile'), class: 'bg-danger' title: t("management.events.event.create_profile"), class: "bg-danger"
end end
end.join(', ').html_safe }.join(", ").html_safe
end end
def participant_names_with_emails(event) def participant_names_with_emails(event)
@ -25,13 +25,11 @@ module EventsHelper
end end
def participant_names(event) def participant_names(event)
event.participants.map do |participant| event.participants.map { |participant|
if participant.personal_profile(event.conference).present? if participant.personal_profile(event.conference).present?
profile = participant.personal_profile(event.conference) profile = participant.personal_profile(event.conference)
"#{profile.name}" profile.name.to_s
else
nil
end end
end.compact }.compact
end end
end end

View File

@ -1,15 +1,14 @@
# coding: utf-8
class EventMailer < ActionMailer::Base class EventMailer < ActionMailer::Base
def confirmation_request(event) def confirmation_request(event)
@event = event @event = event
I18n.locale = @event.proposer.language I18n.locale = @event.proposer.language
mail to: @event.proposer.email, mail to: @event.proposer.email,
from: 'program@openfest.org', from: "program@openfest.org",
subject: I18n.t('event_mailer.acceptance_notification.subject', subject: I18n.t("event_mailer.acceptance_notification.subject",
conference: @event.conference.title, conference: @event.conference.title,
submission_type: @event.event_type.name.mb_chars.downcase.to_s, submission_type: @event.event_type.name.mb_chars.downcase.to_s,
title: @event.title) title: @event.title)
end end
def rejection_notification(event) def rejection_notification(event)
@ -17,11 +16,10 @@ class EventMailer < ActionMailer::Base
I18n.locale = @event.proposer.language I18n.locale = @event.proposer.language
mail to: @event.proposer.email, mail to: @event.proposer.email,
from: 'program@openfest.org', from: "program@openfest.org",
subject: I18n.t('event_mailer.rejection_notification.subject', subject: I18n.t("event_mailer.rejection_notification.subject",
conference: @event.conference.title, conference: @event.conference.title,
submission_type: @event.event_type.name.mb_chars.downcase.to_s, submission_type: @event.event_type.name.mb_chars.downcase.to_s,
title: @event.title) title: @event.title)
end end
end end

View File

@ -1,4 +1,3 @@
# coding: utf-8
class PropositionMailer < ActionMailer::Base class PropositionMailer < ActionMailer::Base
def new_proposition_notification(proposition) def new_proposition_notification(proposition)
@proposition = proposition @proposition = proposition

View File

@ -1,10 +1,9 @@
# coding: utf-8
class VolunteerMailer < ActionMailer::Base class VolunteerMailer < ActionMailer::Base
def team_notification(new_volunteer) def team_notification(new_volunteer)
@volunteer = new_volunteer @volunteer = new_volunteer
mail(to: @volunteer.conference.email, mail(to: @volunteer.conference.email,
subject: "Нов доброволец #{@volunteer.name} <#{@volunteer.email}> за екип(и) #{@volunteer.volunteer_teams.map(&:name).join(', ')}") subject: "Нов доброволец #{@volunteer.name} <#{@volunteer.email}> за екип(и) #{@volunteer.volunteer_teams.map(&:name).join(", ")}")
end end
def volunteer_notification(new_volunteer) def volunteer_notification(new_volunteer)
@ -12,8 +11,8 @@ class VolunteerMailer < ActionMailer::Base
I18n.locale = @volunteer.language I18n.locale = @volunteer.language
mail(to: @volunteer.email, mail(to: @volunteer.email,
reply_to: @volunteer.conference.email, reply_to: @volunteer.conference.email,
from: 'no-reply@openfest.org', from: "no-reply@openfest.org",
subject: I18n.t('volunteer_mailer.success_notification.subject', subject: I18n.t("volunteer_mailer.success_notification.subject",
conference_name: @volunteer.conference.title)) conference_name: @volunteer.conference.title))
end end
end end

View File

@ -2,7 +2,7 @@ class CallForParticipation < ActiveRecord::Base
belongs_to :conference belongs_to :conference
def open! def open!
self.opens_at = Time.now unless self.opens_at.present? self.opens_at = Time.now unless opens_at.present?
self.closes_at = nil self.closes_at = nil
save save
end end
@ -13,14 +13,14 @@ class CallForParticipation < ActiveRecord::Base
end end
def open? def open?
self.opens_at.present? and self.opens_at < Time.now opens_at.present? && (opens_at < Time.now)
end end
def closed? def closed?
self.closes_at.present? and self.closes_at < Time.now closes_at.present? && (closes_at < Time.now)
end end
def in_progress? def in_progress?
open? and not closed? open? && !closed?
end end
end end

View File

@ -14,30 +14,30 @@ class Conference < ActiveRecord::Base
has_many :halls has_many :halls
has_many :event_types has_many :event_types
has_many :events has_many :events
has_many :approved_events, -> { joins(:proposition).approved }, class_name: 'Event' has_many :approved_events, -> { joins(:proposition).approved }, class_name: "Event"
has_many :conflict_counts, through: :events has_many :conflict_counts, through: :events
has_many :volunteer_teams has_many :volunteer_teams
has_many :volunteers has_many :volunteers
has_one :call_for_participation has_one :call_for_participation
has_many :participants, -> { distinct }, class_name: 'User', through: :events has_many :participants, -> { distinct }, class_name: "User", through: :events
has_many :participant_profiles, class_name: 'PersonalProfile' has_many :participant_profiles, class_name: "PersonalProfile"
has_many :slots, through: :halls has_many :slots, through: :halls
has_many :feedbacks, as: :feedback_receiving has_many :feedbacks, as: :feedback_receiving
has_many :editions, primary_key: :host_name, foreign_key: :host_name, class_name: 'Conference' has_many :editions, primary_key: :host_name, foreign_key: :host_name, class_name: "Conference"
has_many :events_of_all_editions, through: :editions, source: :events has_many :events_of_all_editions, through: :editions, source: :events
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams, accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
reject_if: :all_blank, allow_destroy: true reject_if: :all_blank, allow_destroy: true
after_create :create_call_for_participation after_create :create_call_for_participation
def submissions_grouped_by_day def submissions_grouped_by_day
submissions = events.group('date(events.created_at)').select('date(events.created_at) as created_at, count(events.id) as number') submissions = events.group("date(events.created_at)").select("date(events.created_at) as created_at, count(events.id) as number")
submissions.group_by { |s| s.created_at.to_date } submissions.group_by { |s| s.created_at.to_date }
end end
def submissions_grouped_by_confirmation_day def submissions_grouped_by_confirmation_day
submissions = events.joins(:proposition).approved.confirmed.group('date(propositions.confirmed_at)').select('date(propositions.confirmed_at) as confirmed_at, count(events.id) as number') submissions = events.joins(:proposition).approved.confirmed.group("date(propositions.confirmed_at)").select("date(propositions.confirmed_at) as confirmed_at, count(events.id) as number")
submissions.group_by { |s| s.confirmed_at.to_date } submissions.group_by { |s| s.confirmed_at.to_date }
end end
@ -46,7 +46,7 @@ class Conference < ActiveRecord::Base
end end
def has_vote_results? def has_vote_results?
vote_data_updated_at.present? and number_of_ballots_cast > 0 vote_data_updated_at.present? && (number_of_ballots_cast > 0)
end end
def has_voting_endpoint? def has_voting_endpoint?
@ -54,8 +54,8 @@ class Conference < ActiveRecord::Base
end end
def update_conflict_data! def update_conflict_data!
update_vote_data! or raise ActiveRecord::Rollback update_vote_data! || raise(ActiveRecord::Rollback)
events.all? { |event| event.update_conflict_data(false) } or raise ActiveRecord::Rollback events.all? { |event| event.update_conflict_data(false) } || raise(ActiveRecord::Rollback)
end end
def most_conflicts def most_conflicts
@ -74,17 +74,16 @@ class Conference < ActiveRecord::Base
conflict_counts.unscoped.where(left: approved_events, right: approved_events).order(number_of_conflicts: :asc).first.try(:number_of_conflicts) || 0 conflict_counts.unscoped.where(left: approved_events, right: approved_events).order(number_of_conflicts: :asc).first.try(:number_of_conflicts) || 0
end end
private private
def planned_cfp_end_date_is_before_start_date def planned_cfp_end_date_is_before_start_date
if planned_cfp_end_date.present? and start_date.present? and planned_cfp_end_date > start_date if planned_cfp_end_date.present? && start_date.present? && (planned_cfp_end_date > start_date)
errors.add(:planned_cfp_end_date, :cannot_be_after_start_date) errors.add(:planned_cfp_end_date, :cannot_be_after_start_date)
end end
end end
def start_date_is_before_end_date def start_date_is_before_end_date
if start_date.present? and end_date.present? and start_date > end_date if start_date.present? && end_date.present? && (start_date > end_date)
errors.add(:end_date, :cannot_be_before_start_date) errors.add(:end_date, :cannot_be_before_start_date)
end end
end end
@ -95,38 +94,38 @@ class Conference < ActiveRecord::Base
attr_accessor :conference attr_accessor :conference
def number_of_ballots def number_of_ballots
@number_of_ballots ||= remote_summary_data['number_of_ballots'] @number_of_ballots ||= remote_summary_data["number_of_ballots"]
end end
def ranking def ranking
@ranking ||= remote_summary_data['ranking'].map { |ranking_entry| EventRanking.new ranking_entry } @ranking ||= remote_summary_data["ranking"].map { |ranking_entry| EventRanking.new ranking_entry }
end end
def conflicts def conflicts
@conflicts ||= remote_summary_data['conflicts'].map { |conflicts_entry| ConflictsForEvent.new conflicts_entry } @conflicts ||= remote_summary_data["conflicts"].map { |conflicts_entry| ConflictsForEvent.new conflicts_entry }
end end
def save def save
conference.transaction do conference.transaction do
conference.number_of_ballots_cast = number_of_ballots conference.number_of_ballots_cast = number_of_ballots
conflicts.all?(&:save) or raise ActiveRecord::Rollback conflicts.all?(&:save) || raise(ActiveRecord::Rollback)
ranking.all?(&:save) or raise ActiveRecord::Rollback ranking.all?(&:save) || raise(ActiveRecord::Rollback)
conference.touch :vote_data_updated_at conference.touch :vote_data_updated_at
conference.save or raise ActiveRecord::Rollback conference.save || raise(ActiveRecord::Rollback)
end end
end end
private private
def connection def connection
@connection ||= Faraday.new(url: conference.vote_data_endpoint + '/summary.json', @connection ||= Faraday.new(url: conference.vote_data_endpoint + "/summary.json",
headers: {'Content-Type' => 'application/json'}) headers: {"Content-Type" => "application/json"})
end end
def remote_summary_data def remote_summary_data
@remote_summary_data ||= JSON.parse(connection.get do |request| @remote_summary_data ||= JSON.parse(connection.get { |request|
request.body = {summary: {talk_ids: conference.events.pluck(:id)}}.to_json request.body = {summary: {talk_ids: conference.events.pluck(:id)}}.to_json
end.body) }.body)
end end
class ConflictsForEvent class ConflictsForEvent
@ -136,14 +135,13 @@ class Conference < ActiveRecord::Base
def save def save
@event = Event.find(talk_id) @event = Event.find(talk_id)
@event.conflict_counts.destroy_all or raise ActiveRecord::Rollback @event.conflict_counts.destroy_all || raise(ActiveRecord::Rollback)
conflicts.all? do |right_event_id, number_of_conflicts| conflicts.all? do |right_event_id, number_of_conflicts|
ConflictCount.create left_id: talk_id, right_id: right_event_id, number_of_conflicts: number_of_conflicts ConflictCount.create left_id: talk_id, right_id: right_event_id, number_of_conflicts: number_of_conflicts
end or raise ActiveRecord::Rollback end || raise(ActiveRecord::Rollback)
end end
end end
class EventRanking class EventRanking
include ActiveModel::Model include ActiveModel::Model

View File

@ -1,5 +1,5 @@
class ConflictCount < ActiveRecord::Base class ConflictCount < ActiveRecord::Base
belongs_to :left, class_name: 'Event' belongs_to :left, class_name: "Event"
belongs_to :right, class_name: 'Event' belongs_to :right, class_name: "Event"
has_one :conference, through: :left has_one :conference, through: :left
end end

View File

@ -6,8 +6,8 @@ class Event < ActiveRecord::Base
has_one :slot has_one :slot
has_many :participations, dependent: :destroy has_many :participations, dependent: :destroy
has_many :pending_participations, ->() { pending }, class_name: 'Participation' has_many :pending_participations, -> { pending }, class_name: "Participation"
has_many :approved_participations, ->() { approved }, class_name: 'Participation' has_many :approved_participations, -> { approved }, class_name: "Participation"
has_many :participants, through: :approved_participations has_many :participants, through: :approved_participations
has_many :participants_with_personal_profiles, through: :approved_participations, source: :participant_with_personal_profile has_many :participants_with_personal_profiles, through: :approved_participations, source: :participant_with_personal_profile
has_many :conflict_counts, -> { order(number_of_conflicts: :desc) }, foreign_key: :left_id has_many :conflict_counts, -> { order(number_of_conflicts: :desc) }, foreign_key: :left_id
@ -19,7 +19,7 @@ class Event < ActiveRecord::Base
scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})} scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})}
validates :conference, presence: true validates :conference, presence: true
validates :title, presence: true, length: { maximum: 65 } validates :title, presence: true, length: {maximum: 65}
validates :abstract, presence: true validates :abstract, presence: true
validates :description, presence: true validates :description, presence: true
validates :agreement, acceptance: true validates :agreement, acceptance: true
@ -61,16 +61,16 @@ class Event < ActiveRecord::Base
language: language, language: language,
abstract: abstract, abstract: abstract,
description: description, description: description,
notes: notes notes: notes,
} }
end end
def ranked? def ranked?
conference.has_vote_results? and rank.present? and number_of_votes.present? conference.has_vote_results? && rank.present? && number_of_votes.present?
end end
def per_cent_of_votes def per_cent_of_votes
if conference.has_vote_results? and conference.number_of_ballots_cast > 0 if conference.has_vote_results? && (conference.number_of_ballots_cast > 0)
Rational(number_of_votes * 100, conference.number_of_ballots_cast) Rational(number_of_votes * 100, conference.number_of_ballots_cast)
else else
Float::NAN Float::NAN
@ -80,20 +80,20 @@ class Event < ActiveRecord::Base
private private
def event_type_belongs_to_the_selected_conference def event_type_belongs_to_the_selected_conference
unless conference.present? and conference.event_types.include?(event_type) unless conference.present? && conference.event_types.include?(event_type)
errors.add :event_type, :must_be_a_valid_event_type errors.add :event_type, :must_be_a_valid_event_type
end end
end end
def track_belongs_to_the_selected_conference def track_belongs_to_the_selected_conference
unless conference.present? and conference.tracks.include?(track) unless conference.present? && conference.tracks.include?(track)
errors.add :track, :must_be_a_valid_track errors.add :track, :must_be_a_valid_track
end end
end end
def length_is_within_the_permitted_interval def length_is_within_the_permitted_interval
if event_type.present? if event_type.present?
unless length >= event_type.minimum_length and length <= event_type.maximum_length unless (length >= event_type.minimum_length) && (length <= event_type.maximum_length)
errors.add :length, :must_be_between, minimum: event_type.minimum_length, maximum: event_type.maximum_length errors.add :length, :must_be_between, minimum: event_type.minimum_length, maximum: event_type.maximum_length
end end
end end

View File

@ -9,6 +9,6 @@ class EventSearch
option(:confirmed) { |scope, value| scope.joins(:proposition).approved.where.not(propositions: {confirmed_at: nil}) } option(:confirmed) { |scope, value| scope.joins(:proposition).approved.where.not(propositions: {confirmed_at: nil}) }
option(:not_confirmed) { |scope, value| scope.joins(:proposition).approved.where(propositions: {confirmed_at: nil}) } option(:not_confirmed) { |scope, value| scope.joins(:proposition).approved.where(propositions: {confirmed_at: nil}) }
sort_by 'title' sort_by "title"
config[:defaults]['sort'] = "#{config[:sort_attributes].first} asc" config[:defaults]["sort"] = "#{config[:sort_attributes].first} asc"
end end

View File

@ -1,7 +1,7 @@
class Feedback < ActiveRecord::Base class Feedback < ActiveRecord::Base
belongs_to :feedback_receiving, polymorphic: true belongs_to :feedback_receiving, polymorphic: true
validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5 ,6]} validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5, 6]}
before_create :destroy_older_feedbacks_by_the_session before_create :destroy_older_feedbacks_by_the_session

View File

@ -3,7 +3,7 @@ class Participant < ActiveRecord::Base
self.primary_key = :participant_id self.primary_key = :participant_id
def twitter=(handle) def twitter=(handle)
write_attribute :twitter, handle.gsub(/\A@/,'') if handle write_attribute :twitter, handle.gsub(/\A@/, "") if handle
end end
def name def name

View File

@ -1,8 +1,8 @@
class Participation < ActiveRecord::Base class Participation < ActiveRecord::Base
belongs_to :participant, class_name: 'User' belongs_to :participant, class_name: "User"
has_one :participant_with_personal_profile, class_name: 'Participant' has_one :participant_with_personal_profile, class_name: "Participant"
belongs_to :event belongs_to :event
validates :participant_id, presence: true validates :participant_id, presence: true
scope :approved, ->() { where approved: true } scope :approved, -> { where approved: true }
scope :pending, ->() { where.not approved: true } scope :pending, -> { where.not approved: true }
end end

View File

@ -11,14 +11,14 @@ class PersonalProfile < ActiveRecord::Base
validates :twitter, format: {with: /\A[a-z0-9_]{1,15}\z/i}, allow_blank: true validates :twitter, format: {with: /\A[a-z0-9_]{1,15}\z/i}, allow_blank: true
validates :github, format: {with: /\A[a-z0-9][a-z0-9\-]*\z/i}, allow_blank: true validates :github, format: {with: /\A[a-z0-9][a-z0-9\-]*\z/i}, allow_blank: true
phony_normalize :mobile_phone, default_country_code: 'BG', add_plus: false phony_normalize :mobile_phone, default_country_code: "BG", add_plus: false
mount_uploader :picture, PictureUploader mount_uploader :picture, PictureUploader
accepts_nested_attributes_for :user accepts_nested_attributes_for :user
def twitter=(handle) def twitter=(handle)
write_attribute :twitter, handle.gsub(/\A@/,'') if handle write_attribute :twitter, handle.gsub(/\A@/, "") if handle
end end
def name def name

View File

@ -1,5 +1,5 @@
class Proposition < ActiveRecord::Base class Proposition < ActiveRecord::Base
belongs_to :proposer, class_name: 'User' belongs_to :proposer, class_name: "User"
belongs_to :proposable, polymorphic: true, dependent: :destroy belongs_to :proposable, polymorphic: true, dependent: :destroy
enum status: [:undecided, :approved, :rejected, :backup] enum status: [:undecided, :approved, :rejected, :backup]
delegate :proposable_title, :proposable_type, :proposable_description, to: :proposable delegate :proposable_title, :proposable_type, :proposable_description, to: :proposable

View File

@ -9,7 +9,7 @@ class Track < ActiveRecord::Base
translates :name, :description translates :name, :description
def color=(hex_triplet) def color=(hex_triplet)
write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet write_attribute :color, hex_triplet.gsub(/\A#/, "") if hex_triplet
end end
def color def color

View File

@ -2,13 +2,13 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :lockable, :timeoutable and :omniauthable # :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable, devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
has_many :personal_profiles, dependent: :destroy has_many :personal_profiles, dependent: :destroy
has_many :lectures has_many :lectures
has_many :workshops has_many :workshops
has_many :propositions, foreign_key: :proposer_id has_many :propositions, foreign_key: :proposer_id
has_many :events, through: :propositions, source: :proposable, source_type: 'Event' has_many :events, through: :propositions, source: :proposable, source_type: "Event"
has_many :participations, foreign_key: :participant_id has_many :participations, foreign_key: :participant_id
has_many :events_participated_in, through: :participations, source: :event has_many :events_participated_in, through: :participations, source: :event
has_many :volunteerships, foreign_key: :volunteer_id has_many :volunteerships, foreign_key: :volunteer_id

View File

@ -14,7 +14,7 @@ class Volunteer < ActiveRecord::Base
validates :volunteer_teams, presence: true validates :volunteer_teams, presence: true
validate :volunteer_teams_belong_to_conference validate :volunteer_teams_belong_to_conference
phony_normalize :phone, default_country_code: 'BG' phony_normalize :phone, default_country_code: "BG"
belongs_to :conference belongs_to :conference
has_and_belongs_to_many :volunteer_teams has_and_belongs_to_many :volunteer_teams

View File

@ -3,6 +3,6 @@ class VolunteerSearch
option(:volunteer_team_id) { |scope, value| scope.joins(:volunteer_teams).where volunteer_teams: {id: value} } option(:volunteer_team_id) { |scope, value| scope.joins(:volunteer_teams).where volunteer_teams: {id: value} }
sort_by 'name' sort_by "name"
config[:defaults]['sort'] = "#{config[:sort_attributes].first} asc" config[:defaults]["sort"] = "#{config[:sort_attributes].first} asc"
end end

View File

@ -13,7 +13,7 @@ class VolunteerTeam < ActiveRecord::Base
end end
def color=(hex_triplet) def color=(hex_triplet)
write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet write_attribute :color, hex_triplet.gsub(/\A#/, "") if hex_triplet
end end
def color def color

View File

@ -2,7 +2,7 @@ class Volunteership < ActiveRecord::Base
include Proposable include Proposable
belongs_to :volunteer_team belongs_to :volunteer_team
belongs_to :volunteer, class_name: 'User' belongs_to :volunteer, class_name: "User"
has_one :conference, through: :volunteer_team has_one :conference, through: :volunteer_team
def proposable_title def proposable_title

View File

@ -1,7 +1,6 @@
class PictureUploader < CarrierWave::Uploader::Base class PictureUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support: # Include RMagick or MiniMagick support:
#include CarrierWave::RMagick # include CarrierWave::RMagick
include CarrierWave::MiniMagick include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader: # Choose what kind of storage to use for this uploader:
@ -16,7 +15,7 @@ class PictureUploader < CarrierWave::Uploader::Base
# Provide a default URL as a default if there hasn't been a file uploaded: # Provide a default URL as a default if there hasn't been a file uploaded:
def default_url def default_url
ActionController::Base.helpers.asset_path("fallback/profile_picture/" + [version_name, "default.png"].compact.join('_')) ActionController::Base.helpers.asset_path("fallback/profile_picture/" + [version_name, "default.png"].compact.join("_"))
end end
# Process files as they are uploaded: # Process files as they are uploaded:
@ -29,21 +28,21 @@ class PictureUploader < CarrierWave::Uploader::Base
# Create different versions of your uploaded files: # Create different versions of your uploaded files:
version :medium do version :medium do
process :resize_to_fit => [171, 180] process resize_to_fit: [171, 180]
end end
version :thumb do version :thumb do
process :resize_to_fit => [50, 50] process resize_to_fit: [50, 50]
end end
version :schedule do version :schedule do
process :resize_to_fill => [100, 100] process resize_to_fill: [100, 100]
end end
# Add a white list of extensions which are allowed to be uploaded. # Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this: # For images you might use something like this:
def extension_white_list def extension_white_list
%w(jpg jpeg png) %w[jpg jpeg png]
end end
# Override the filename of the uploaded files: # Override the filename of the uploaded files:
@ -51,5 +50,4 @@ class PictureUploader < CarrierWave::Uploader::Base
# def filename # def filename
# "something.jpg" if original_filename # "something.jpg" if original_filename
# end # end
end end

View File

@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path("../config/environment", __FILE__)
run Rails.application run Rails.application

View File

@ -1,6 +1,6 @@
require_relative 'boot' require_relative "boot"
require 'rails/all' require "rails/all"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
@ -18,7 +18,7 @@ module Clarion
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Sofia' config.time_zone = "Sofia"
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
@ -29,12 +29,12 @@ module Clarion
config.generators do |g| config.generators do |g|
g.test_framework :rspec, fixtures: true, g.test_framework :rspec, fixtures: true,
view_specs: false, view_specs: false,
helper_specs: false, helper_specs: false,
routing_specs: false, routing_specs: false,
request_specs: false request_specs: false
g.fixture_replacement :factory_bot, dir: 'spec/factories' g.fixture_replacement :factory_bot, dir: "spec/factories"
end end
end end
end end

View File

@ -1,4 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require "bundler/setup" # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations. require "bootsnap/setup" # Speed up boot time by caching expensive operations.

View File

@ -1,14 +1,14 @@
# config valid only for current version of Capistrano # config valid only for current version of Capistrano
lock '3.11.0' lock "3.11.0"
set :application, 'clarion' set :application, "clarion"
set :repo_url, 'https://github.com/ignisf/clarion.git' set :repo_url, "https://github.com/ignisf/clarion.git"
# Default branch is :master # Default branch is :master
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app # Default deploy_to directory is /var/www/my_app
set :deploy_to, '/home/barf/clarion' set :deploy_to, "/home/barf/clarion"
# Default value for :scm is :git # Default value for :scm is :git
# set :scm, :git # set :scm, :git
@ -23,10 +23,10 @@ set :deploy_to, '/home/barf/clarion'
# set :pty, true # set :pty, true
# Default value for :linked_files is [] # Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml') set :linked_files, fetch(:linked_files, []).push("config/database.yml", "config/secrets.yml")
# Default value for linked_dirs is [] # Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/uploads', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') set :linked_dirs, fetch(:linked_dirs, []).push("log", "tmp/uploads", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", "public/system", "public/uploads")
# Default value for default_env is {} # Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" } # set :default_env, { path: "/opt/ruby/bin:$PATH" }
@ -34,7 +34,7 @@ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/uploads', 'tmp/pids',
# Default value for keep_releases is 5 # Default value for keep_releases is 5
set :keep_releases, 10 set :keep_releases, 10
set :rvm_ruby_version, '2.2.2' set :rvm_ruby_version, "2.2.2"
set :puma_bind, ["tcp://127.0.0.1:9087"] set :puma_bind, ["tcp://127.0.0.1:9087"]
set :puma_init_active_record, true set :puma_init_active_record, true
@ -42,12 +42,11 @@ set :puma_access_log, "#{shared_path}/log/puma_access.log"
set :puma_error_log, "#{shared_path}/log/puma_error.log" set :puma_error_log, "#{shared_path}/log/puma_error.log"
set :puma_preload_app, true set :puma_preload_app, true
set :nginx_sites_available_path, "#{shared_path}" set :nginx_sites_available_path, shared_path.to_s
set :nginx_sites_enabled_path, "/tmp" set :nginx_sites_enabled_path, "/tmp"
set :nginx_server_name, 'cfp.openfest.org' set :nginx_server_name, "cfp.openfest.org"
namespace :deploy do namespace :deploy do
after :restart, :clear_cache do after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as: # Here we can do anything such as:

View File

@ -5,9 +5,7 @@
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
server 'marla.ludost.net', user: 'barf', roles: %w{app db web} server "marla.ludost.net", user: "barf", roles: %w[app db web]
# role-based syntax # role-based syntax
# ================== # ==================
@ -21,8 +19,6 @@ server 'marla.ludost.net', user: 'barf', roles: %w{app db web}
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com} # role :db, %w{deploy@example.com}
# Configuration # Configuration
# ============= # =============
# You can set any configuration variable like in config/deploy.rb # You can set any configuration variable like in config/deploy.rb
@ -31,8 +27,6 @@ server 'marla.ludost.net', user: 'barf', roles: %w{app db web}
# http://capistranorb.com/documentation/getting-started/configuration/ # http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup. # Feel free to add new variables to customise your setup.
# Custom SSH Options # Custom SSH Options
# ================== # ==================
# You may pass any option but keep in mind that net/ssh understands a # You may pass any option but keep in mind that net/ssh understands a
@ -42,9 +36,9 @@ server 'marla.ludost.net', user: 'barf', roles: %w{app db web}
# Global options # Global options
# -------------- # --------------
set :ssh_options, { set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa), # keys: %w(/home/rlisowski/.ssh/id_rsa),
forward_agent: true, forward_agent: true,
# auth_methods: %w(password) # auth_methods: %w(password)
} }
# #
# The server-based syntax can be used to override options: # The server-based syntax can be used to override options:

View File

@ -1,5 +1,5 @@
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative "application"
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View File

@ -14,12 +14,12 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist? if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}" "Cache-Control" => "public, max-age=#{2.days.to_i}",
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@ -34,8 +34,8 @@ Rails.application.configure do
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Use localhost for default host # Use localhost for default host
config.action_mailer.default_url_options = {host: 'localhost:3000'} config.action_mailer.default_url_options = {host: "localhost:3000"}
config.action_mailer.default_options = {from: 'no-reply@example.com'} config.action_mailer.default_options = {from: "no-reply@example.com"}
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.

View File

@ -20,7 +20,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@ -54,7 +54,7 @@ Rails.application.configure do
config.log_level = :debug config.log_level = :debug
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
config.log_tags = [ :request_id ] config.log_tags = [:request_id]
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
@ -70,8 +70,8 @@ Rails.application.configure do
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :sendmail config.action_mailer.delivery_method = :sendmail
config.action_mailer.default_options = {from: 'no-reply@openfest.org'} config.action_mailer.default_options = {from: "no-reply@openfest.org"}
config.action_mailer.default_url_options = {host: 'cfp.openfest.org'} config.action_mailer.default_url_options = {host: "cfp.openfest.org"}
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).

View File

@ -15,7 +15,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}" "Cache-Control" => "public, max-age=#{1.hour.to_i}",
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.
@ -39,8 +39,8 @@ Rails.application.configure do
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Use localhost for default host # Use localhost for default host
config.action_mailer.default_url_options = {host: 'localhost:3000'} config.action_mailer.default_url_options = {host: "localhost:3000"}
config.action_mailer.default_options = {from: 'no-reply@example.com'} config.action_mailer.default_options = {from: "no-reply@example.com"}
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr

View File

@ -1,19 +1,19 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path. # Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path. # Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules') Rails.application.config.assets.paths << Rails.root.join("node_modules")
Rails.application.config.assets.paths << 'lib/initfest/assets/images' Rails.application.config.assets.paths << "lib/initfest/assets/images"
Rails.application.config.assets.paths << 'lib/initfest/assets/javascripts' Rails.application.config.assets.paths << "lib/initfest/assets/javascripts"
Rails.application.config.assets.paths << 'lib/initfest/assets/stylesheets' Rails.application.config.assets.paths << "lib/initfest/assets/stylesheets"
Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/ Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added. # folder are already added.
Rails.application.config.assets.precompile += %w( management/application.css management/application.js ) Rails.application.config.assets.precompile += %w[management/application.css management/application.js]

View File

@ -12,7 +12,7 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer, # Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class # note that it will be overwritten if you use your own mailer class
# with default "from" parameter. # with default "from" parameter.
config.mailer_sender = 'no-reply@openfest.org' config.mailer_sender = "no-reply@openfest.org"
# Configure the class responsible to send e-mails. # Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer' # config.mailer = 'Devise::Mailer'
@ -21,7 +21,7 @@ Devise.setup do |config|
# Load and configure the ORM. Supports :active_record (default) and # Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be # :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems. # available as additional gems.
require 'devise/orm/active_record' require "devise/orm/active_record"
# ==> Configuration for any authentication mechanism # ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is # Configure which keys are used when authenticating a user. The default is

View File

@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_clarion_session' Rails.application.config.session_store :cookie_store, key: "_clarion_session"

View File

@ -6,7 +6,7 @@ SimpleForm.setup do |config|
# stack. The options given below are used to wrap the # stack. The options given below are used to wrap the
# whole input. # whole input.
config.wrappers :default, class: :input, config.wrappers :default, class: :input,
hint_class: :field_with_hint, error_class: :field_with_errors do |b| hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default ## Extensions enabled by default
# Any of these extensions can be disabled for a # Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`. # given input by passing: `f.input EXTENSION_NAME => false`.
@ -41,8 +41,8 @@ SimpleForm.setup do |config|
## Inputs ## Inputs
b.use :label_input b.use :label_input
b.use :hint, wrap_with: { tag: :span, class: :hint } b.use :hint, wrap_with: {tag: :span, class: :hint}
b.use :error, wrap_with: { tag: :span, class: :error } b.use :error, wrap_with: {tag: :span, class: :error}
## full_messages_for ## full_messages_for
# If you want to display the full error message for the attribute, you can # If you want to display the full error message for the attribute, you can
@ -61,7 +61,7 @@ SimpleForm.setup do |config|
config.boolean_style = :nested config.boolean_style = :nested
# Default class for buttons # Default class for buttons
config.button_class = 'btn' config.button_class = "btn"
# Method used to tidy up errors. Specify any Rails Array method. # Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field. # :first lists the first message for each field.
@ -72,7 +72,7 @@ SimpleForm.setup do |config|
config.error_notification_tag = :div config.error_notification_tag = :div
# CSS class to add for error notification helper. # CSS class to add for error notification helper.
config.error_notification_class = 'error_notification' config.error_notification_class = "error_notification"
# ID to add for error notification helper. # ID to add for error notification helper.
# config.error_notification_id = nil # config.error_notification_id = nil
@ -155,7 +155,7 @@ SimpleForm.setup do |config|
# config.input_class = nil # config.input_class = nil
# Define the default class of the input wrapper of the boolean input. # Define the default class of the input wrapper of the boolean input.
config.boolean_label_class = 'checkbox' config.boolean_label_class = "checkbox"
# Defines if the default input wrapper class should be included in radio # Defines if the default input wrapper class should be included in radio
# collection wrappers. # collection wrappers.

View File

@ -1,125 +1,125 @@
# Use this setup block to configure all options available in SimpleForm. # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config| SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger' config.error_notification_class = "alert alert-danger"
config.button_class = 'btn btn-default' config.button_class = "btn btn-default"
config.boolean_label_class = nil config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :vertical_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
b.optional :maxlength b.optional :maxlength
b.optional :pattern b.optional :pattern
b.optional :min_max b.optional :min_max
b.optional :readonly b.optional :readonly
b.use :label, class: 'control-label' b.use :label, class: "control-label"
b.use :input, class: 'form-control' b.use :input, class: "form-control"
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: {tag: "span", class: "help-block"}
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :vertical_file_input, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
b.optional :maxlength b.optional :maxlength
b.optional :readonly b.optional :readonly
b.use :label, class: 'control-label' b.use :label, class: "control-label"
b.use :input b.use :input
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: {tag: "span", class: "help-block"}
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :vertical_boolean, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.optional :readonly b.optional :readonly
b.wrapper tag: 'div', class: 'checkbox' do |ba| b.wrapper tag: "div", class: "checkbox" do |ba|
ba.use :label_input ba.use :label_input
end end
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: {tag: "span", class: "help-block"}
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :vertical_radio_and_checkboxes, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.optional :readonly b.optional :readonly
b.use :label, class: 'control-label' b.use :label, class: "control-label"
b.use :input b.use :input
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: {tag: "span", class: "help-block"}
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :horizontal_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
b.optional :maxlength b.optional :maxlength
b.optional :pattern b.optional :pattern
b.optional :min_max b.optional :min_max
b.optional :readonly b.optional :readonly
b.use :label, class: 'col-sm-3 control-label' b.use :label, class: "col-sm-3 control-label"
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| b.wrapper tag: "div", class: "col-sm-9" do |ba|
ba.use :input, class: 'form-control' ba.use :input, class: "form-control"
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } ba.use :error, wrap_with: {tag: "span", class: "help-block"}
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
end end
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :horizontal_file_input, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
b.optional :maxlength b.optional :maxlength
b.optional :readonly b.optional :readonly
b.use :label, class: 'col-sm-3 control-label' b.use :label, class: "col-sm-3 control-label"
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| b.wrapper tag: "div", class: "col-sm-9" do |ba|
ba.use :input ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } ba.use :error, wrap_with: {tag: "span", class: "help-block"}
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
end end
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :horizontal_boolean, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.optional :readonly b.optional :readonly
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| b.wrapper tag: "div", class: "col-sm-offset-3 col-sm-9" do |wr|
wr.wrapper tag: 'div', class: 'checkbox' do |ba| wr.wrapper tag: "div", class: "checkbox" do |ba|
ba.use :label_input, class: 'col-sm-9' ba.use :label_input, class: "col-sm-9"
end end
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } wr.use :error, wrap_with: {tag: "span", class: "help-block"}
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } wr.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
end end
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :horizontal_radio_and_checkboxes, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.optional :readonly b.optional :readonly
b.use :label, class: 'col-sm-3 control-label' b.use :label, class: "col-sm-3 control-label"
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| b.wrapper tag: "div", class: "col-sm-9" do |ba|
ba.use :input ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } ba.use :error, wrap_with: {tag: "span", class: "help-block"}
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
end end
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :inline_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
b.optional :maxlength b.optional :maxlength
b.optional :pattern b.optional :pattern
b.optional :min_max b.optional :min_max
b.optional :readonly b.optional :readonly
b.use :label, class: 'sr-only' b.use :label, class: "sr-only"
b.use :input, class: 'form-control' b.use :input, class: "form-control"
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: {tag: "span", class: "help-block"}
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: {tag: "p", class: "help-block"}
end end
# Wrappers for forms and inputs using the Bootstrap toolkit. # Wrappers for forms and inputs using the Bootstrap toolkit.

View File

@ -1,19 +1,19 @@
Rails.application.routes.draw do Rails.application.routes.draw do
devise_for :users, controllers: {registrations: 'registrations', confirmations: 'confirmations'} devise_for :users, controllers: {registrations: "registrations", confirmations: "confirmations"}
scope module: :public do scope module: :public do
root to: 'home#index' root to: "home#index"
resource :personal_profile, path: 'profile' resource :personal_profile, path: "profile"
resources :events do resources :events do
resources :feedback, controller: 'event_feedbacks', only: [:new, :create] resources :feedback, controller: "event_feedbacks", only: [:new, :create]
resource :feedback_qr_code, controller: 'event_feedback_qrcodes', only: :show resource :feedback_qr_code, controller: "event_feedback_qrcodes", only: :show
member do member do
get :confirm get :confirm
end end
end end
resources :volunteers resources :volunteers
resources :volunteer_teams, only: [:index] resources :volunteer_teams, only: [:index]
resources :feedback, as: 'conference_feedbacks', controller: 'conference_feedbacks', only: [:new, :create, :index] resources :feedback, as: "conference_feedbacks", controller: "conference_feedbacks", only: [:new, :create, :index]
end end
namespace :api do namespace :api do
@ -33,7 +33,7 @@ Rails.application.routes.draw do
end end
namespace :management do namespace :management do
root to: 'conferences#index' root to: "conferences#index"
resources :conferences do resources :conferences do
member do member do

View File

@ -1,6 +1,6 @@
%w( %w[
.ruby-version .ruby-version
.rbenv-vars .rbenv-vars
tmp/restart.txt tmp/restart.txt
tmp/caching-dev.txt tmp/caching-dev.txt
).each { |path| Spring.watch(path) } ].each { |path| Spring.watch(path) }

View File

@ -33,7 +33,7 @@ class DeviseCreateUsers < ActiveRecord::Migration[4.2]
t.string :first_name, null: false t.string :first_name, null: false
t.string :last_name, null: false t.string :last_name, null: false
t.string :organisation t.string :organisation
t.boolean :hide_email, null: false, default: true t.boolean :hide_email, null: false, default: true
t.string :photo_url t.string :photo_url
t.string :mobile_phone, null: false t.string :mobile_phone, null: false
t.text :biography t.text :biography

View File

@ -5,7 +5,7 @@ class CreateEvents < ActiveRecord::Migration[4.2]
t.string :subtitle t.string :subtitle
t.string :type t.string :type
t.integer :length, null: false, default: 45 t.integer :length, null: false, default: 45
t.string :language, null: false, default: 'bg_BG' t.string :language, null: false, default: "bg_BG"
t.integer :state t.integer :state
t.text :abstract, null: false t.text :abstract, null: false
t.text :description, null: false t.text :description, null: false

View File

@ -1,14 +1,14 @@
class AddTranslationTablesToConferences < ActiveRecord::Migration[4.2] class AddTranslationTablesToConferences < ActiveRecord::Migration[4.2]
def up def up
Conference.create_translation_table!({ Conference.create_translation_table!({
:title => :string, title: :string,
:description => :text description: :text,
}, { }, {
:migrate_data => true migrate_data: true,
}) })
end end
def down def down
Conference.drop_translation_table! :migrate_data => true Conference.drop_translation_table! migrate_data: true
end end
end end

View File

@ -1,11 +1,11 @@
class AddTranslationTablesToTracks < ActiveRecord::Migration[4.2] class AddTranslationTablesToTracks < ActiveRecord::Migration[4.2]
def up def up
Track.create_translation_table!({ Track.create_translation_table!({
name: :string, name: :string,
description: :text description: :text,
}, { }, {
migrate_data: true migrate_data: true,
}) })
end end
def down def down

View File

@ -1,6 +1,6 @@
class ChangeEventStateDefaults < ActiveRecord::Migration[4.2] class ChangeEventStateDefaults < ActiveRecord::Migration[4.2]
def up def up
execute 'UPDATE events SET state = 0' execute "UPDATE events SET state = 0"
change_column :events, :state, :integer, null: false, default: 0 change_column :events, :state, :integer, null: false, default: 0
end end

View File

@ -3,7 +3,7 @@ class CreatePropositions < ActiveRecord::Migration[4.2]
create_table :propositions do |t| create_table :propositions do |t|
t.references :proposer, index: true t.references :proposer, index: true
t.references :proposition_accepting, polymorphic: true t.references :proposition_accepting, polymorphic: true
t.index [:proposition_accepting_id, :proposition_accepting_type], name: 'proposition_accepting_index' t.index [:proposition_accepting_id, :proposition_accepting_type], name: "proposition_accepting_index"
t.references :proposable, polymorphic: true, index: true t.references :proposable, polymorphic: true, index: true
t.integer :status t.integer :status

View File

@ -1,15 +1,15 @@
class CreatePropositionsForExistingEvents < ActiveRecord::Migration[4.2] class CreatePropositionsForExistingEvents < ActiveRecord::Migration[4.2]
def up def up
events = execute 'SELECT * FROM events' events = execute "SELECT * FROM events"
events.each do |event| events.each do |event|
execute "INSERT INTO propositions (proposer_id, proposition_accepting_id, proposition_accepting_type, proposable_id, proposable_type, status, created_at, updated_at) execute "INSERT INTO propositions (proposer_id, proposition_accepting_id, proposition_accepting_type, proposable_id, proposable_type, status, created_at, updated_at)
VALUES (#{event['user_id']}, #{event['track_id']}, 'Track', #{event['id']}, 'Event', #{event['state']}, '#{event['created_at']}', '#{event['updated_at']}')" VALUES (#{event["user_id"]}, #{event["track_id"]}, 'Track', #{event["id"]}, 'Event', #{event["state"]}, '#{event["created_at"]}', '#{event["updated_at"]}')"
end end
end end
def down def down
event_ids = execute('SELECT * FROM events').map { |event| event['id'] } event_ids = execute("SELECT * FROM events").map { |event| event["id"] }
execute "DELETE FROM propositions WHERE proposable_id IN (#{event_ids.join(', ')}) AND proposable_type = 'Event'" execute "DELETE FROM propositions WHERE proposable_id IN (#{event_ids.join(", ")}) AND proposable_type = 'Event'"
end end
end end

View File

@ -9,10 +9,10 @@ class CreateEventTypesForAllExistingEvents < ActiveRecord::Migration[4.2]
GROUP BY type_name, tracks.conference_id;' GROUP BY type_name, tracks.conference_id;'
event_types.each do |type| event_types.each do |type|
event_type = EventType.create! conference_id: type['conference_id'], created_at: type['created_at'], updated_at: type['created_at'] event_type = EventType.create! conference_id: type["conference_id"], created_at: type["created_at"], updated_at: type["created_at"]
execute "INSERT INTO event_type_translations (event_type_id, locale, created_at, updated_at, name, description) execute "INSERT INTO event_type_translations (event_type_id, locale, created_at, updated_at, name, description)
VALUES (#{event_type.id}, 'en', '#{event_type.created_at}', '#{event_type.created_at}', '#{type['type_name']}', 'None');" VALUES (#{event_type.id}, 'en', '#{event_type.created_at}', '#{event_type.created_at}', '#{type["type_name"]}', 'None');"
end end
end end

View File

@ -1,14 +1,14 @@
class PopulateEventTypeOfExistingEvents < ActiveRecord::Migration[4.2] class PopulateEventTypeOfExistingEvents < ActiveRecord::Migration[4.2]
def up def up
event_ids = execute('SELECT id FROM events WHERE type IS NOT NULL;').map { |row| row['id'] }; event_ids = execute("SELECT id FROM events WHERE type IS NOT NULL;").map { |row| row["id"] }
event_ids.each do |id| event_ids.each do |id|
event_type_id = execute("SELECT ett.event_type_id FROM events JOIN event_type_translations AS ett ON events.type = ett.name WHERE events.id = #{id};").first['event_type_id'] event_type_id = execute("SELECT ett.event_type_id FROM events JOIN event_type_translations AS ett ON events.type = ett.name WHERE events.id = #{id};").first["event_type_id"]
execute("UPDATE events SET event_type_id = #{event_type_id} WHERE id = #{id}"); execute("UPDATE events SET event_type_id = #{event_type_id} WHERE id = #{id}")
end end
end end
def down def down
execute("UPDATE events SET event_type_id = NULL"); execute("UPDATE events SET event_type_id = NULL")
end end
end end

View File

@ -3,13 +3,13 @@ class PersonalProfile < ActiveRecord::Base; end
class CreateParticipationRecords < ActiveRecord::Migration[4.2] class CreateParticipationRecords < ActiveRecord::Migration[4.2]
def up def up
event_to_speaker_profiles = execute 'SELECT * FROM events_speaker_profiles' event_to_speaker_profiles = execute "SELECT * FROM events_speaker_profiles"
event_to_speaker_profiles.each do |event_to_speaker_profile| event_to_speaker_profiles.each do |event_to_speaker_profile|
profile = PersonalProfile.find_by(id: event_to_speaker_profile['speaker_profile_id']) profile = PersonalProfile.find_by(id: event_to_speaker_profile["speaker_profile_id"])
next if not profile next unless profile
Participation.create! event_id: event_to_speaker_profile['event_id'], Participation.create! event_id: event_to_speaker_profile["event_id"],
participant_id: profile.user_id, participant_id: profile.user_id,
approved: true approved: true
end end

View File

@ -1,13 +1,13 @@
class AddTranslationsToHalls < ActiveRecord::Migration[4.2] class AddTranslationsToHalls < ActiveRecord::Migration[4.2]
def self.up def self.up
Hall.create_translation_table!({ Hall.create_translation_table!({
:name => :string name: :string,
}, { }, {
:migrate_data => true migrate_data: true,
}) })
end end
def self.down def self.down
Hall.drop_translation_table! :migrate_data => true Hall.drop_translation_table! migrate_data: true
end end
end end

View File

@ -1,8 +1,8 @@
class CreateJoinTableVolunteerVolunteerTeam < ActiveRecord::Migration[4.2] class CreateJoinTableVolunteerVolunteerTeam < ActiveRecord::Migration[4.2]
def change def change
create_join_table :volunteers, :volunteer_teams do |t| create_join_table :volunteers, :volunteer_teams do |t|
t.index [:volunteer_id, :volunteer_team_id], name: 'volunteer_id_volunteer_team_id' t.index [:volunteer_id, :volunteer_team_id], name: "volunteer_id_volunteer_team_id"
t.index [:volunteer_team_id, :volunteer_id], name: 'volunteer_team_id_volunteer_id' t.index [:volunteer_team_id, :volunteer_id], name: "volunteer_team_id_volunteer_id"
end end
end end
end end

View File

@ -3,7 +3,7 @@ end
class AddDescriptionsForAllEvents < ActiveRecord::Migration[4.2] class AddDescriptionsForAllEvents < ActiveRecord::Migration[4.2]
def up def up
Event.where(description: [nil, '']).update_all(description: 'n/a') Event.where(description: [nil, ""]).update_all(description: "n/a")
end end
def down def down

View File

@ -1,16 +1,16 @@
PARTICIPANTS_SQL = <<EOS PARTICIPANTS_SQL = <<~EOS
CREATE VIEW "participants" AS CREATE VIEW "participants" AS
SELECT "users"."id" AS "participant_id", SELECT "users"."id" AS "participant_id",
"users"."email" AS personal_email, "users"."email" AS personal_email,
"users"."language" AS language, "users"."language" AS language,
"participations"."id" AS "participation_id", "participations"."id" AS "participation_id",
"personal_profiles"."id" AS "personal_profile_id", "personal_profiles"."id" AS "personal_profile_id",
"personal_profiles".* FROM "users" "personal_profiles".* FROM "users"
INNER JOIN "participations" ON "users"."id" = "participations"."participant_id" INNER JOIN "participations" ON "users"."id" = "participations"."participant_id"
INNER JOIN "events" ON "events"."id" = "participations"."event_id" INNER JOIN "events" ON "events"."id" = "participations"."event_id"
INNER JOIN "conferences" ON "events"."conference_id" = "conferences"."id" INNER JOIN "conferences" ON "events"."conference_id" = "conferences"."id"
LEFT JOIN "personal_profiles" ON "personal_profiles"."conference_id" = "events"."conference_id" LEFT JOIN "personal_profiles" ON "personal_profiles"."conference_id" = "events"."conference_id"
AND "personal_profiles"."user_id" = "users"."id"; AND "personal_profiles"."user_id" = "users"."id";
EOS EOS
class AddParticipantsView < ActiveRecord::Migration[4.2] class AddParticipantsView < ActiveRecord::Migration[4.2]

View File

@ -5,8 +5,8 @@
# #
# 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
User.create(email: 'foo@example.com', User.create(email: "foo@example.com",
password: '123qweASD', password: "123qweASD",
password_confirmation: '123qweASD', password_confirmation: "123qweASD",
confirmed_at: Time.current, confirmed_at: Time.current,
admin: true) admin: true)

View File

@ -7,7 +7,7 @@ task :backup, [:destination] => :environment do |t, args|
silent = Rake.application.options.silent silent = Rake.application.options.silent
puts "Backing up '#{conf[:database]}' into: #{args.destination}" unless silent puts "Backing up '#{conf[:database]}' into: #{args.destination}" unless silent
if system(cmd) if system(cmd)
puts 'Backup completed.' unless silent puts "Backup completed." unless silent
else else
puts "Backup failed!\nCommand exit status: #{$?}\nCommand was: #{cmd}" puts "Backup failed!\nCommand exit status: #{$?}\nCommand was: #{cmd}"
end end

View File

@ -1,34 +1,34 @@
require 'fileutils' require "fileutils"
require 'yaml' require "yaml"
require 'securerandom' require "securerandom"
namespace :bootstrap do namespace :bootstrap do
desc 'Copy over initial db config' desc "Copy over initial db config"
task :db_config do task :db_config do
example_config_file = File.join(Rails.root, 'config', 'database.yml.example') example_config_file = File.join(Rails.root, "config", "database.yml.example")
new_config_file = File.join(Rails.root, 'config', 'database.yml') new_config_file = File.join(Rails.root, "config", "database.yml")
FileUtils.cp example_config_file, new_config_file FileUtils.cp example_config_file, new_config_file
end end
desc 'Generate new secret tokens' desc "Generate new secret tokens"
task :secret_tokens do task :secret_tokens do
secret_tokens_file = File.join Rails.root, 'config', 'secrets.yml' secret_tokens_file = File.join Rails.root, "config", "secrets.yml"
secrets = { secrets = {
'development' => {'secret_key_base' => SecureRandom.hex(64)}, "development" => {"secret_key_base" => SecureRandom.hex(64)},
'test' => {'secret_key_base' => SecureRandom.hex(64)}, "test" => {"secret_key_base" => SecureRandom.hex(64)},
'production' => {'secret_key_base' => '<%= ENV["SECRET_KEY_BASE"] %>'} "production" => {"secret_key_base" => '<%= ENV["SECRET_KEY_BASE"] %>'},
} }
File.open(secret_tokens_file, 'w') do |f| File.open(secret_tokens_file, "w") do |f|
f.puts secrets.to_yaml f.puts secrets.to_yaml
end end
end end
end end
desc 'Perform initial setup of the application' desc "Perform initial setup of the application"
task bootstrap: ['bootstrap:secret_tokens', task bootstrap: ["bootstrap:secret_tokens",
'bootstrap:db_config', "bootstrap:db_config",
'db:create', "db:create",
'db:migrate', "db:migrate",
'db:test:prepare'] "db:test:prepare",]

View File

@ -3,11 +3,11 @@
FactoryBot.define do FactoryBot.define do
factory :conference do factory :conference do
sequence(:title) { |n| "Conference-#{n}" } sequence(:title) { |n| "Conference-#{n}" }
email { 'foo@example.com' } email { "foo@example.com" }
description { 'MyText' } description { "MyText" }
start_date { '2014-07-29 21:29:13' } start_date { "2014-07-29 21:29:13" }
end_date { '2014-07-31 21:29:13' } end_date { "2014-07-31 21:29:13" }
planned_cfp_end_date { '2014-07-28' } planned_cfp_end_date { "2014-07-28" }
factory :past_conference do factory :past_conference do
start_date { Date.today - 10.days } start_date { Date.today - 10.days }

View File

@ -1,9 +1,9 @@
FactoryBot.define do FactoryBot.define do
factory :event_type do factory :event_type do
name { |n| "Track #{n}" } name { |n| "Track #{n}" }
description { 'MyText' } description { "MyText" }
conference conference
minimum_length { '45' } minimum_length { "45" }
maximum_length { '60' } maximum_length { "60" }
end end
end end

View File

@ -2,8 +2,8 @@ FactoryBot.define do
factory :event do factory :event do
title { |n| "Event #{n}" } title { |n| "Event #{n}" }
length { 60 } length { 60 }
abstract { 'foo' } abstract { "foo" }
description { 'foo' } description { "foo" }
conference conference
language { :bg } language { :bg }
after(:build) do |event, evaluator| after(:build) do |event, evaluator|

View File

@ -1,14 +1,14 @@
FactoryBot.define do FactoryBot.define do
factory :personal_profile do factory :personal_profile do
first_name { 'Foo' } first_name { "Foo" }
last_name { 'Bar' } last_name { "Bar" }
organisation { 'foo inc.' } organisation { "foo inc." }
public_email { 'foo@example.com' } public_email { "foo@example.com" }
picture { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'picture.jpg')) } picture { Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "picture.jpg")) }
mobile_phone { '+359883444555' } mobile_phone { "+359883444555" }
biography { 'Just a bio' } biography { "Just a bio" }
github { 'foobar' } github { "foobar" }
twitter { 'foobar' } twitter { "foobar" }
user user
conference conference
end end

View File

@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :track do factory :track do
name { |n| "Track#{n}" } name { |n| "Track#{n}" }
color { '#000000' } color { "#000000" }
description { 'Some description' } description { "Some description" }
conference conference
end end
end end

View File

@ -4,8 +4,8 @@ FactoryBot.define do
sequence(:email) { |n| "user-#{n}@example.org" } sequence(:email) { |n| "user-#{n}@example.org" }
factory :user do factory :user do
password { 'password' } password { "password" }
password_confirmation { 'password' } password_confirmation { "password" }
confirmed_at { Time.now - 15.minutes } confirmed_at { Time.now - 15.minutes }
email email

View File

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
feature 'Call for papers' do feature "Call for papers" do
before do before do
Rails.application.load_seed Rails.application.load_seed
end end
@ -11,21 +11,21 @@ feature 'Call for papers' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase)) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase))
click_on I18n.t(:registration) click_on I18n.t(:registration)
register_a_new_user(false) register_a_new_user(false)
submit_an_event_proposition submit_an_event_proposition
expect(page).to have_content I18n.t('views.events.event_successfully_created', event_type: Event.last.event_type.name.mb_chars.downcase) expect(page).to have_content I18n.t("views.events.event_successfully_created", event_type: Event.last.event_type.name.mb_chars.downcase)
expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile) expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile)
fill_in_personal_profile fill_in_personal_profile
expect(page).to have_content I18n.t('views.personal_profiles.successfully_created') expect(page).to have_content I18n.t("views.personal_profiles.successfully_created")
click_on I18n.t('views.navigation.my_submissions') click_on I18n.t("views.navigation.my_submissions")
expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"') expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"')
@ -41,7 +41,7 @@ feature 'Call for papers' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase)) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase))
click_on I18n.t(:registration) click_on I18n.t(:registration)
register_a_new_user(false) register_a_new_user(false)
@ -57,17 +57,17 @@ feature 'Call for papers' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase)) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase))
sign_in_as_an_existing_user(false) sign_in_as_an_existing_user(false)
submit_an_event_proposition(false) submit_an_event_proposition(false)
expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile) expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile)
click_on I18n.t('helpers.submit.create', model: PersonalProfile.model_name.human) click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human)
expect(page).to have_content I18n.t('views.personal_profiles.successfully_created') expect(page).to have_content I18n.t("views.personal_profiles.successfully_created")
click_on I18n.t('views.navigation.my_submissions') click_on I18n.t("views.navigation.my_submissions")
expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"') expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"')
@ -76,7 +76,6 @@ feature 'Call for papers' do
verify_the_event_is_submitted verify_the_event_is_submitted
end end
scenario "A returning user resets their password and submits an event proposition" do scenario "A returning user resets their password and submits an event proposition" do
time_travel_to(2.years.ago) do time_travel_to(2.years.ago) do
sign_in_as_admin sign_in_as_admin
@ -84,7 +83,7 @@ feature 'Call for papers' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase)) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase))
click_on I18n.t(:registration) click_on I18n.t(:registration)
register_a_new_user(false) register_a_new_user(false)
@ -100,25 +99,25 @@ feature 'Call for papers' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase)) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.try(:mb_chars).try(:downcase))
click_on I18n.t('lostpass') click_on I18n.t("lostpass")
fill_in User.human_attribute_name(:email), with: 'bar@example.com' fill_in User.human_attribute_name(:email), with: "bar@example.com"
click_on I18n.t(:send_lostpass_instructions) click_on I18n.t(:send_lostpass_instructions)
expect(page).to have_content I18n.t('devise.passwords.send_instructions') expect(page).to have_content I18n.t("devise.passwords.send_instructions")
visit ActionMailer::Base.deliveries.last.body.raw_source.match(/https?:\/\/.*?(\/.*\w)/)[1] visit ActionMailer::Base.deliveries.last.body.raw_source.match(/https?:\/\/.*?(\/.*\w)/)[1]
fill_in User.human_attribute_name(:password), with: 'foobarbaz' fill_in User.human_attribute_name(:password), with: "foobarbaz"
fill_in User.human_attribute_name(:password_confirmation), with: 'foobarbaz' fill_in User.human_attribute_name(:password_confirmation), with: "foobarbaz"
click_on I18n.t(:change_pass) click_on I18n.t(:change_pass)
submit_an_event_proposition(false) submit_an_event_proposition(false)
expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile) expect(page).to have_content I18n.t(:please_fill_in_your_speaker_profile)
click_on I18n.t('helpers.submit.create', model: PersonalProfile.model_name.human) click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human)
expect(page).to have_content I18n.t('views.personal_profiles.successfully_created') expect(page).to have_content I18n.t("views.personal_profiles.successfully_created")
click_on I18n.t('views.navigation.my_submissions') click_on I18n.t("views.navigation.my_submissions")
expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"') expect(page).to have_content(Event.last.event_type.name + ' "This is just a sample title of an event"')

View File

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
feature 'Landing page' do feature "Landing page" do
before do before do
Rails.application.load_seed Rails.application.load_seed
sign_in_as_admin sign_in_as_admin
@ -8,9 +8,8 @@ feature 'Landing page' do
sign_out sign_out
end end
it 'displays information about the conference' do it "displays information about the conference" do
visit root_path visit root_path
expect(page).to have_content I18n.t(:home_title, conference: "FooConf #{1.year.from_now.year}") expect(page).to have_content I18n.t(:home_title, conference: "FooConf #{1.year.from_now.year}")
end end
end end

View File

@ -1,11 +1,11 @@
require "rails_helper" require "rails_helper"
feature 'Conference management' do feature "Conference management" do
before do before do
Rails.application.load_seed Rails.application.load_seed
end end
scenario 'Creating a new conference' do scenario "Creating a new conference" do
sign_in_as_admin sign_in_as_admin
visit management_root_path visit management_root_path
expect(page).to_not have_content "FooConf" expect(page).to_not have_content "FooConf"
@ -14,104 +14,104 @@ feature 'Conference management' do
expect(page).to have_content "FooConf" expect(page).to have_content "FooConf"
end end
scenario 'Enabling the call for papers of a conference' do scenario "Enabling the call for papers of a conference" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
visit root_path visit root_path
expect(page).to have_link I18n.t('views.welcome.submit_event', event_type: '') expect(page).to have_link I18n.t("views.welcome.submit_event", event_type: "")
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('management.conferences.show.cfp_status') click_on I18n.t("management.conferences.show.cfp_status")
expect(page).to_not have_link I18n.t('views.welcome.submit_event', event_type: '') expect(page).to_not have_link I18n.t("views.welcome.submit_event", event_type: "")
end end
scenario 'Editing an existing conference' do scenario "Editing an existing conference" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
click_on I18n.t('actions.edit.button', model: Conference.model_name.human) click_on I18n.t("actions.edit.button", model: Conference.model_name.human)
fill_in Conference.human_attribute_name(:title), with: 'FooBarBazConf' fill_in Conference.human_attribute_name(:title), with: "FooBarBazConf"
page.find('.btn.btn-primary').click page.find(".btn.btn-primary").click
expect(page).to have_content 'FooBarBazConf' expect(page).to have_content "FooBarBazConf"
end end
scenario 'Deleting a newly created conference', js: true do scenario "Deleting a newly created conference", js: true do
sign_in_as_admin sign_in_as_admin
create_new_conference(host_name: '127.0.0.1') create_new_conference(host_name: "127.0.0.1")
click_on 'Clarion' click_on "Clarion"
expect(page).to have_content 'FooConf' expect(page).to have_content "FooConf"
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
accept_confirm do accept_confirm do
click_on I18n.t('actions.destroy.button', model: Conference.model_name.human) click_on I18n.t("actions.destroy.button", model: Conference.model_name.human)
end end
visit management_root_path visit management_root_path
expect(page).to_not have_content 'FooConf' expect(page).to_not have_content "FooConf"
end end
scenario 'Reviewing an event' do scenario "Reviewing an event" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
submit_an_event_proposition(true) submit_an_event_proposition(true)
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.event', count: 2).capitalize click_on I18n.t("activerecord.models.event", count: 2).capitalize
click_on I18n.t('actions.view.button', model: Event.model_name.human) click_on I18n.t("actions.view.button", model: Event.model_name.human)
expect(page).to have_content('This is just a sample title of an event') expect(page).to have_content("This is just a sample title of an event")
end end
scenario 'Editing an event' do scenario "Editing an event" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
submit_an_event_proposition(true) submit_an_event_proposition(true)
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.event', count: 2).capitalize click_on I18n.t("activerecord.models.event", count: 2).capitalize
expect(page).to have_content('This is just a sample title of an event') expect(page).to have_content("This is just a sample title of an event")
click_on I18n.t('actions.edit.button', model: Event.model_name.human) click_on I18n.t("actions.edit.button", model: Event.model_name.human)
fill_in Event.human_attribute_name(:title), with: 'This is just a sample edited title of an event' fill_in Event.human_attribute_name(:title), with: "This is just a sample edited title of an event"
click_on I18n.t('helpers.submit.event.update') click_on I18n.t("helpers.submit.event.update")
expect(page).to have_content I18n.t('management.events.update.event_successfully_updated') expect(page).to have_content I18n.t("management.events.update.event_successfully_updated")
expect(page).to have_content 'This is just a sample edited title of an event' expect(page).to have_content "This is just a sample edited title of an event"
end end
scenario 'Approving an event from its detailed view' do scenario "Approving an event from its detailed view" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
submit_an_event_proposition(true) submit_an_event_proposition(true)
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.event', count: 2).capitalize click_on I18n.t("activerecord.models.event", count: 2).capitalize
expect(page).to_not have_button I18n.t("status.approved") expect(page).to_not have_button I18n.t("status.approved")
click_on I18n.t('actions.view.button', model: Event.model_name.human) click_on I18n.t("actions.view.button", model: Event.model_name.human)
click_on I18n.t("status.undecided") click_on I18n.t("status.undecided")
click_on I18n.t("status.approved") click_on I18n.t("status.approved")
click_on I18n.t('activerecord.models.event', count: 2).capitalize click_on I18n.t("activerecord.models.event", count: 2).capitalize
expect(page).to have_button I18n.t("status.approved") expect(page).to have_button I18n.t("status.approved")
end end
scenario 'Approving an event from the events index' do scenario "Approving an event from the events index" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
submit_an_event_proposition(true) submit_an_event_proposition(true)
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.event', count: 2).capitalize click_on I18n.t("activerecord.models.event", count: 2).capitalize
expect(page).to_not have_button I18n.t("status.approved") expect(page).to_not have_button I18n.t("status.approved")
click_on I18n.t("status.undecided") click_on I18n.t("status.undecided")
click_on I18n.t("status.approved") click_on I18n.t("status.approved")
expect(page).to have_button I18n.t("status.approved") expect(page).to have_button I18n.t("status.approved")
end end
scenario 'Creating a profile for a submitter' do scenario "Creating a profile for a submitter" do
sign_in_as_admin sign_in_as_admin
create_new_conference create_new_conference
submit_an_event_proposition(true) submit_an_event_proposition(true)
visit management_root_path visit management_root_path
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.personal_profile', count: 2).capitalize click_on I18n.t("activerecord.models.personal_profile", count: 2).capitalize
click_on I18n.t('actions.create.title', model: PersonalProfile.model_name.human) click_on I18n.t("actions.create.title", model: PersonalProfile.model_name.human)
fill_in_personal_profile fill_in_personal_profile
expect(page).to have_content I18n.t('management.personal_profiles.create.successfully_created') expect(page).to have_content I18n.t("management.personal_profiles.create.successfully_created")
expect(page).to have_content 'Foo Bar' expect(page).to have_content "Foo Bar"
end end
scenario "Cloning the last profile of a submitter that did not update it when they submitted" do scenario "Cloning the last profile of a submitter that did not update it when they submitted" do
@ -121,7 +121,7 @@ feature 'Conference management' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.downcase) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.downcase)
click_on I18n.t(:registration) click_on I18n.t(:registration)
register_a_new_user(false) register_a_new_user(false)
@ -137,7 +137,7 @@ feature 'Conference management' do
sign_out sign_out
visit root_path visit root_path
click_on I18n.t('views.welcome.submit_event', event_type: Conference.first.event_types.first.name.downcase) click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.downcase)
sign_in_as_an_existing_user(false) sign_in_as_an_existing_user(false)
@ -146,12 +146,11 @@ feature 'Conference management' do
sign_out sign_out
verify_the_event_is_submitted verify_the_event_is_submitted
click_on I18n.t('activerecord.models.personal_profile', count: 2).capitalize click_on I18n.t("activerecord.models.personal_profile", count: 2).capitalize
expect(page).to have_text(I18n.t('management.personal_profiles.index.no_profile')) expect(page).to have_text(I18n.t("management.personal_profiles.index.no_profile"))
click_on I18n.t('actions.clone.title', model: PersonalProfile.model_name.human) click_on I18n.t("actions.clone.title", model: PersonalProfile.model_name.human)
expect(page).to have_text(I18n.t('management.personal_profiles.create.successfully_created')) expect(page).to have_text(I18n.t("management.personal_profiles.create.successfully_created"))
click_on I18n.t('activerecord.models.personal_profile', count: 2).capitalize click_on I18n.t("activerecord.models.personal_profile", count: 2).capitalize
expect(page).to_not have_text(I18n.t('management.personal_profiles.index.no_profile')) expect(page).to_not have_text(I18n.t("management.personal_profiles.index.no_profile"))
end end
end end

View File

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
feature 'Volunteering' do feature "Volunteering" do
before do before do
Rails.application.load_seed Rails.application.load_seed
sign_in_as_admin sign_in_as_admin
@ -8,16 +8,16 @@ feature 'Volunteering' do
sign_out sign_out
end end
scenario 'A user applies to be a volunteer for the upcoming conference' do scenario "A user applies to be a volunteer for the upcoming conference" do
visit root_path visit root_path
click_on I18n.t('views.volunteers.apply') click_on I18n.t("views.volunteers.apply")
fill_in_volunteer_profile fill_in_volunteer_profile
expect(page).to have_content I18n.t('views.volunteers.successful_application') expect(page).to have_content I18n.t("views.volunteers.successful_application")
sign_in_as_admin sign_in_as_admin
click_on_first_conference_in_management_root click_on_first_conference_in_management_root
click_on I18n.t('activerecord.models.volunteership', count: 2).capitalize click_on I18n.t("activerecord.models.volunteership", count: 2).capitalize
expect(page).to have_content 'Volunteer Foo' expect(page).to have_content "Volunteer Foo"
end end
end end

View File

@ -1,70 +1,70 @@
require 'rails_helper' require "rails_helper"
RSpec.describe CallForParticipation, type: :model do RSpec.describe CallForParticipation, type: :model do
let(:conference) { create :conference } let(:conference) { create :conference }
subject(:cfp) { build :call_for_participation, conference_id: conference.id } subject(:cfp) { build :call_for_participation, conference_id: conference.id }
it 'belongs to a conference' do it "belongs to a conference" do
conference = create :conference conference = create :conference
cfp = create(:call_for_participation, conference_id: conference.id) cfp = create(:call_for_participation, conference_id: conference.id)
expect(CallForParticipation.find(cfp.id).conference).to eq conference expect(CallForParticipation.find(cfp.id).conference).to eq conference
end end
describe '#open?' do describe "#open?" do
it 'returns true when the CFP has an opens_at date in the past' do it "returns true when the CFP has an opens_at date in the past" do
cfp.opens_at = 10.minutes.ago cfp.opens_at = 10.minutes.ago
expect(cfp.open?).to be true expect(cfp.open?).to be true
end end
it 'returns false when the CFP has no opens_at date' do it "returns false when the CFP has no opens_at date" do
cfp.opens_at = nil cfp.opens_at = nil
expect(cfp.open?).to be false expect(cfp.open?).to be false
end end
it 'returns false when the CFP has an opens_at date in the future' do it "returns false when the CFP has an opens_at date in the future" do
cfp.opens_at = 10.minutes.from_now cfp.opens_at = 10.minutes.from_now
expect(cfp.open?).to be false expect(cfp.open?).to be false
end end
end end
describe '#closed?' do describe "#closed?" do
it 'returns true when the CFP has a closes_at date in the past' do it "returns true when the CFP has a closes_at date in the past" do
cfp.closes_at = 10.minutes.ago cfp.closes_at = 10.minutes.ago
expect(cfp.closed?).to be true expect(cfp.closed?).to be true
end end
it 'returns false when the CFP has no closes_at date' do it "returns false when the CFP has no closes_at date" do
cfp.closes_at = nil cfp.closes_at = nil
expect(cfp.closed?).to be false expect(cfp.closed?).to be false
end end
it 'returns false when the CFP has a closes_at date in the future' do it "returns false when the CFP has a closes_at date in the future" do
cfp.closes_at = 10.minutes.from_now cfp.closes_at = 10.minutes.from_now
expect(cfp.closed?).to be false expect(cfp.closed?).to be false
end end
end end
describe '#in_progress?' do describe "#in_progress?" do
it 'returns true when the CFP has been opened and has not been closed' do it "returns true when the CFP has been opened and has not been closed" do
expect(cfp).to receive(:open?) { true } expect(cfp).to receive(:open?) { true }
expect(cfp).to receive(:closed?) { false } expect(cfp).to receive(:closed?) { false }
expect(cfp.in_progress?).to be true expect(cfp.in_progress?).to be true
end end
it 'returns false when the CFP has not been opened' do it "returns false when the CFP has not been opened" do
expect(cfp).to receive(:open?) { false } expect(cfp).to receive(:open?) { false }
expect(cfp.in_progress?).to be false expect(cfp.in_progress?).to be false
end end
it 'returns false when the CFP has been closed' do it "returns false when the CFP has been closed" do
expect(cfp).to receive(:open?) { true } expect(cfp).to receive(:open?) { true }
expect(cfp).to receive(:closed?) { true } expect(cfp).to receive(:closed?) { true }
@ -72,32 +72,32 @@ RSpec.describe CallForParticipation, type: :model do
end end
end end
describe '#open!' do describe "#open!" do
it 'changes the status of the CFP to open' do it "changes the status of the CFP to open" do
expect { cfp.open! }.to change { cfp.open? }.from(false).to(true) expect { cfp.open! }.to change { cfp.open? }.from(false).to(true)
end end
it 'does not change the open time of the CFP when it has already been set' do it "does not change the open time of the CFP when it has already been set" do
cfp.opens_at = 10.minutes.ago cfp.opens_at = 10.minutes.ago
expect { cfp.open! }.to_not change { cfp.opens_at } expect { cfp.open! }.to_not change { cfp.opens_at }
end end
it 'unsets the close time of the CFP' do it "unsets the close time of the CFP" do
cfp.closes_at = 10.minutes.ago cfp.closes_at = 10.minutes.ago
expect { cfp.open! }.to change { cfp.closes_at }.to(nil) expect { cfp.open! }.to change { cfp.closes_at }.to(nil)
end end
it 'saves the record' do it "saves the record" do
expect { cfp.open! }.to change { cfp.persisted? }.from(false).to(true) expect { cfp.open! }.to change { cfp.persisted? }.from(false).to(true)
end end
end end
describe '#close!' do describe "#close!" do
it 'changes the status of the CFP to closed' do it "changes the status of the CFP to closed" do
expect { cfp.close! }.to change { cfp.closed? }.from(false).to(true) expect { cfp.close! }.to change { cfp.closed? }.from(false).to(true)
end end
it 'saves the record' do it "saves the record" do
expect { cfp.close! }.to change { cfp.persisted? }.from(false).to(true) expect { cfp.close! }.to change { cfp.persisted? }.from(false).to(true)
end end
end end

View File

@ -1,57 +1,57 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Conference, :type => :model do RSpec.describe Conference, type: :model do
describe 'title' do describe "title" do
it 'must not be blank' do it "must not be blank" do
expect(build(:conference, title: '')).to have_error_on :title expect(build(:conference, title: "")).to have_error_on :title
end end
it 'must be unique' do it "must be unique" do
create :conference, title: 'ExampleConf' create :conference, title: "ExampleConf"
expect(build(:conference, title: 'ExampleConf')).to have_error_on :title expect(build(:conference, title: "ExampleConf")).to have_error_on :title
end end
it 'must be translatable' do it "must be translatable" do
conference = build(:conference) conference = build(:conference)
expect(conference).to have_translatable :title expect(conference).to have_translatable :title
end end
end end
describe 'email' do describe "email" do
it 'must be present' do it "must be present" do
expect(build(:conference, email: '')).to have_error_on :email expect(build(:conference, email: "")).to have_error_on :email
end end
it 'can contain exatly one @' do it "can contain exatly one @" do
expect(build(:conference, email: 'test@@example.com')).to have_error_on :email expect(build(:conference, email: "test@@example.com")).to have_error_on :email
expect(build(:conference, email: 'test@example.com')).to_not have_error_on :email expect(build(:conference, email: "test@example.com")).to_not have_error_on :email
expect(build(:conference, email: 'testexample.com')).to have_error_on :email expect(build(:conference, email: "testexample.com")).to have_error_on :email
end end
end end
describe 'description' do describe "description" do
it 'must be present' do it "must be present" do
expect(build(:conference, description: '')).to have_error_on :description expect(build(:conference, description: "")).to have_error_on :description
end end
it 'must be translatable' do it "must be translatable" do
expect(build(:conference)).to have_translatable :description expect(build(:conference)).to have_translatable :description
end end
end end
it 'is invalid without a start date' do it "is invalid without a start date" do
expect(build(:conference, start_date: nil)).to have_error_on :start_date expect(build(:conference, start_date: nil)).to have_error_on :start_date
end end
it 'is invalid without an end date' do it "is invalid without an end date" do
expect(build(:conference, end_date: nil)).to have_error_on :end_date expect(build(:conference, end_date: nil)).to have_error_on :end_date
end end
it 'is invalid when the end date is before the start date' do it "is invalid when the end date is before the start date" do
expect(build(:conference, start_date: '2014-07-29 21:29:13', end_date: '2014-07-28 01:00:00')).to have_error_on :end_date expect(build(:conference, start_date: "2014-07-29 21:29:13", end_date: "2014-07-28 01:00:00")).to have_error_on :end_date
end end
describe 'tracks association' do describe "tracks association" do
let(:conference) { build :conference } let(:conference) { build :conference }
let(:track) { build :track } let(:track) { build :track }
@ -61,12 +61,12 @@ RSpec.describe Conference, :type => :model do
track.save track.save
end end
it 'links the conference to its tracks' do it "links the conference to its tracks" do
expect(conference.tracks).to include track expect(conference.tracks).to include track
end end
end end
describe 'halls association' do describe "halls association" do
let(:conference) { build :conference } let(:conference) { build :conference }
let(:hall) { build :hall } let(:hall) { build :hall }
@ -76,12 +76,12 @@ RSpec.describe Conference, :type => :model do
hall.save hall.save
end end
it 'has many associated halls' do it "has many associated halls" do
expect(conference.halls).to include hall expect(conference.halls).to include hall
end end
end end
describe 'call for participation association' do describe "call for participation association" do
let(:conference) { build :conference } let(:conference) { build :conference }
let(:call_for_participation) { build :call_for_participation } let(:call_for_participation) { build :call_for_participation }
@ -91,54 +91,54 @@ RSpec.describe Conference, :type => :model do
call_for_participation.save call_for_participation.save
end end
it 'has one call for participation' do it "has one call for participation" do
expect(conference.call_for_participation).to eq call_for_participation expect(conference.call_for_participation).to eq call_for_participation
end end
it 'destroys the associated call for participation when destroyed' do it "destroys the associated call for participation when destroyed" do
conference.destroy conference.destroy
expect { CallForParticipation.find(call_for_participation.id) }.to raise_exception ActiveRecord::RecordNotFound expect { CallForParticipation.find(call_for_participation.id) }.to raise_exception ActiveRecord::RecordNotFound
end end
it 'creates an associated call for participation when the conference is created' do it "creates an associated call for participation when the conference is created" do
conference.save conference.save
expect(conference.call_for_participation).to be_present expect(conference.call_for_participation).to be_present
end end
end end
it 'accepts nested attributes for tracks' do it "accepts nested attributes for tracks" do
track_attributes = build(:track, conference: nil).attributes track_attributes = build(:track, conference: nil).attributes
conference = create :conference conference = create :conference
expect { conference.update tracks_attributes: [track_attributes]}.to change { conference.tracks.count }.by 1 expect { conference.update tracks_attributes: [track_attributes]}.to change { conference.tracks.count }.by 1
end end
it 'rejects nested attributes for tracks when they are all blank' do it "rejects nested attributes for tracks when they are all blank" do
conference = create :conference conference = create :conference
expect { conference.update tracks_attributes: [{'name' => '', 'description' => ''}]}.to_not change { conference.tracks.count } expect { conference.update tracks_attributes: [{"name" => "", "description" => ""}]}.to_not change { conference.tracks.count }
end end
it 'allows destruction of tracks by nested attributes' do it "allows destruction of tracks by nested attributes" do
conference = create :conference conference = create :conference
track_attributes = create(:track, conference: conference).attributes track_attributes = create(:track, conference: conference).attributes
track_attributes['_destroy'] = 1 track_attributes["_destroy"] = 1
expect { conference.update tracks_attributes: [track_attributes]}.to change { conference.tracks.count }.by(-1) expect { conference.update tracks_attributes: [track_attributes]}.to change { conference.tracks.count }.by(-1)
end end
it 'accepts nested attributes for halls' do it "accepts nested attributes for halls" do
hall_attributes = build(:hall, conference: nil).attributes hall_attributes = build(:hall, conference: nil).attributes
conference = create :conference conference = create :conference
expect { conference.update halls_attributes: [hall_attributes]}.to change { conference.halls.count }.by 1 expect { conference.update halls_attributes: [hall_attributes]}.to change { conference.halls.count }.by 1
end end
it 'rejects nested attributes for halls when they are all blank' do it "rejects nested attributes for halls when they are all blank" do
conference = create :conference conference = create :conference
expect { conference.update halls_attributes: [{'name' => '', 'description' => ''}]}.to_not change { conference.halls.count } expect { conference.update halls_attributes: [{"name" => "", "description" => ""}]}.to_not change { conference.halls.count }
end end
it 'allows destruction of halls by nested attributes' do it "allows destruction of halls by nested attributes" do
conference = create :conference conference = create :conference
hall_attributes = create(:hall, conference: conference).attributes hall_attributes = create(:hall, conference: conference).attributes
hall_attributes['_destroy'] = 1 hall_attributes["_destroy"] = 1
expect { conference.update halls_attributes: [hall_attributes]}.to change { conference.halls.count }.by(-1) expect { conference.update halls_attributes: [hall_attributes]}.to change { conference.halls.count }.by(-1)
end end
end end

View File

@ -1,42 +1,42 @@
require 'rails_helper' require "rails_helper"
describe Event, type: :model do describe Event, type: :model do
let(:event) { build :event } let(:event) { build :event }
it 'is invalid if the event agrement is not accepted' do it "is invalid if the event agrement is not accepted" do
event.agreement = false event.agreement = false
expect(event).to have_error_on :agreement expect(event).to have_error_on :agreement
end end
it 'is invalid without a title' do it "is invalid without a title" do
event.title = '' event.title = ""
expect(event).to have_error_on :title expect(event).to have_error_on :title
end end
describe 'length' do describe "length" do
it 'must be present' do it "must be present" do
event.length = '' event.length = ""
expect(event).to have_error_on :length expect(event).to have_error_on :length
end end
it 'must be a number' do it "must be a number" do
event.length = 'foo' event.length = "foo"
expect(event).to have_error_on :length expect(event).to have_error_on :length
end end
it 'must be larger than zero' do it "must be larger than zero" do
event.length = '-10' event.length = "-10"
expect(event).to have_error_on :length expect(event).to have_error_on :length
end end
end end
it 'is invalid without an abstract' do it "is invalid without an abstract" do
event.abstract = '' event.abstract = ""
expect(event).to have_error_on :abstract expect(event).to have_error_on :abstract
end end
it 'is invalid without a description' do it "is invalid without a description" do
event.description = '' event.description = ""
expect(event).to have_error_on :description expect(event).to have_error_on :description
end end
end end

View File

@ -1,32 +1,31 @@
require 'rails_helper' require "rails_helper"
RSpec.describe EventType, type: :model do RSpec.describe EventType, type: :model do
describe "description" do
describe 'description' do it "must be present" do
it 'must be present' do
expect(build(:event_type, description: nil)).to have_error_on :description expect(build(:event_type, description: nil)).to have_error_on :description
end end
it 'is translatable' do it "is translatable" do
event_type = build(:event_type) event_type = build(:event_type)
expect(event_type).to have_translatable :description expect(event_type).to have_translatable :description
end end
end end
describe 'name' do describe "name" do
it 'must be present' do it "must be present" do
expect(build(:event_type, name: nil)).to have_error_on :name expect(build(:event_type, name: nil)).to have_error_on :name
expect(build(:event_type, name: '')).to have_error_on :name expect(build(:event_type, name: "")).to have_error_on :name
end end
it 'must be unique for a event_type' do it "must be unique for a event_type" do
conference = create :conference conference = create :conference
create :event_type, name: 'foo', conference: conference create :event_type, name: "foo", conference: conference
expect(build(:event_type, name: 'foo', conference: conference)).to have_error_on :name expect(build(:event_type, name: "foo", conference: conference)).to have_error_on :name
expect(build(:event_type, name: 'foo', conference: create(:conference))).to_not have_error_on :name expect(build(:event_type, name: "foo", conference: create(:conference))).to_not have_error_on :name
end end
it 'is translatable' do it "is translatable" do
event_type = build(:event_type) event_type = build(:event_type)
expect(event_type).to have_translatable :name expect(event_type).to have_translatable :name
end end

View File

@ -1,22 +1,22 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Hall, :type => :model do RSpec.describe Hall, type: :model do
it 'is invalid without a name' do it "is invalid without a name" do
expect(build(:hall, name: '')).to have_error_on :name expect(build(:hall, name: "")).to have_error_on :name
end end
it 'belongs to a conference' do it "belongs to a conference" do
conference = create :conference conference = create :conference
expect(build(:hall, conference_id: conference.id).conference).to eq conference expect(build(:hall, conference_id: conference.id).conference).to eq conference
end end
it 'has many slots' do it "has many slots" do
hall = create :hall hall = create :hall
slot = create :slot, hall: hall slot = create :slot, hall: hall
expect(hall.slots).to include slot expect(hall.slots).to include slot
end end
it 'destroys all associated slots when destroyed' do it "destroys all associated slots when destroyed" do
hall = create :hall hall = create :hall
create :slot, hall: hall create :slot, hall: hall
expect { hall.destroy }.to change { Slot.count }.by(-1) expect { hall.destroy }.to change { Slot.count }.by(-1)

View File

@ -1,15 +1,15 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Proposition, type: :model do RSpec.describe Proposition, type: :model do
it 'belongs to a proposer' do it "belongs to a proposer" do
user = create :user user = create :user
expect(create(:proposition, proposer: user).proposer).to eq user expect(create(:proposition, proposer: user).proposer).to eq user
end end
it 'belongs to a proposable' do it "belongs to a proposable" do
event = create :event event = create :event
expect(create(:proposition, proposable: event).proposable).to eq event expect(create(:proposition, proposable: event).proposable).to eq event
end end
it 'is invalid without an existing proposable' it "is invalid without an existing proposable"
end end

View File

@ -1,12 +1,12 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Slot, :type => :model do RSpec.describe Slot, type: :model do
it 'belongs to a hall' do it "belongs to a hall" do
hall = create :hall hall = create :hall
expect(build(:slot, hall_id: hall.id).hall).to eq hall expect(build(:slot, hall_id: hall.id).hall).to eq hall
end end
it 'belongs to an event' do it "belongs to an event" do
event = create :event event = create :event
expect(build(:slot, event_id: event.id).event).to eq event expect(build(:slot, event_id: event.id).event).to eq event
end end

View File

@ -1,23 +1,23 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Track, :type => :model do RSpec.describe Track, type: :model do
it 'is invalid without a name' do it "is invalid without a name" do
expect(build(:track, name: '')).to have_error_on :name expect(build(:track, name: "")).to have_error_on :name
end end
describe 'color' do describe "color" do
it 'must be present' do it "must be present" do
expect(build(:track, color: '')).to have_error_on :color expect(build(:track, color: "")).to have_error_on :color
end end
it 'must be a hex RGB triplet' do it "must be a hex RGB triplet" do
expect(build(:track, color: 'foobar')).to have_error_on :color expect(build(:track, color: "foobar")).to have_error_on :color
expect(build(:track, color: '000000')).to_not have_error_on :color expect(build(:track, color: "000000")).to_not have_error_on :color
expect(build(:track, color: '#000000')).to_not have_error_on :color expect(build(:track, color: "#000000")).to_not have_error_on :color
end end
end end
it 'belongs to a conference' do it "belongs to a conference" do
conference = create :conference conference = create :conference
expect(build(:track, conference_id: conference.id).conference).to eq conference expect(build(:track, conference_id: conference.id).conference).to eq conference
end end

View File

@ -1,7 +1,7 @@
require 'rails_helper' require "rails_helper"
RSpec.describe User do RSpec.describe User do
it 'lets Devise handle email and password validations' do it "lets Devise handle email and password validations" do
expect(build(:user)).to be_a Devise::Models::Validatable expect(build(:user)).to be_a Devise::Models::Validatable
end end
end end

View File

@ -1,4 +1,4 @@
require 'rails_helper' require "rails_helper"
RSpec.describe Volunteership, type: :model do RSpec.describe Volunteership, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"

View File

@ -2,10 +2,10 @@
# SimpleCov.start 'rails' # SimpleCov.start 'rails'
# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV["RAILS_ENV"] ||= "test"
require 'spec_helper' require "spec_helper"
require File.expand_path("../../config/environment", __FILE__) require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails' require "rspec/rails"
# Requires supporting ruby files with custom matchers and macros, etc, in # Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@ -28,7 +28,7 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your # If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false # examples within a transaction, remove the following line or assign false
# instead of true. # instead of true.
#config.use_transactional_fixtures = true # config.use_transactional_fixtures = true
# RSpec Rails can automatically mix in different behaviours to your tests # RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and # based on their file location, for example enabling you to call `get` and

View File

@ -30,7 +30,7 @@ RSpec.configure do |config|
# Use the documentation formatter for detailed output, # Use the documentation formatter for detailed output,
# unless a formatter has already been configured # unless a formatter has already been configured
# (e.g. via a command-line flag). # (e.g. via a command-line flag).
config.default_formatter = 'doc' config.default_formatter = "doc"
end end
# Print the 10 slowest examples and example groups at the # Print the 10 slowest examples and example groups at the

View File

@ -1,7 +1,7 @@
Capybara.default_max_wait_time = 5 Capybara.default_max_wait_time = 5
Capybara.asset_host = 'http://localhost:3000' Capybara.asset_host = "http://localhost:3000"
Capybara.server = :puma, { Silent: true } Capybara.server = :puma, {Silent: true}
Capybara.javascript_driver = :selenium_chrome_headless Capybara.javascript_driver = :selenium_chrome_headless
# RSpec.configure do |config| # RSpec.configure do |config|

View File

@ -27,7 +27,7 @@ RSpec.configure do |config|
# with the specs, so continue to use transaction strategy for speed. # with the specs, so continue to use transaction strategy for speed.
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
if !driver_shares_db_connection_with_specs unless driver_shares_db_connection_with_specs
# Driver is probably for an external browser with an app # Driver is probably for an external browser with an app
# under test that does *not* share a database connection with the # under test that does *not* share a database connection with the
# specs, so use truncation strategy. # specs, so use truncation strategy.

Some files were not shown because too many files have changed in this diff Show More