diff --git a/Capfile b/Capfile index 9b62e32..6a7be94 100644 --- a/Capfile +++ b/Capfile @@ -1,8 +1,8 @@ # Load DSL and set up stages -require 'capistrano/setup' +require "capistrano/setup" # Include default deployment tasks -require 'capistrano/deploy' +require "capistrano/deploy" require "capistrano/scm/git" install_plugin Capistrano::SCM::Git @@ -21,13 +21,13 @@ install_plugin Capistrano::SCM::Git # require 'capistrano/rvm' # require 'capistrano/rbenv' # require 'capistrano/chruby' -require 'capistrano/bundler' -require 'capistrano/rails/assets' -require 'capistrano/rails/migrations' -require 'capistrano/puma' +require "capistrano/bundler" +require "capistrano/rails/assets" +require "capistrano/rails/migrations" +require "capistrano/puma" # require 'capistrano/puma/nginx' # if you want to upload a nginx site template # require 'capistrano/passenger' # require 'capistrano/rvm' # 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 } diff --git a/Gemfile b/Gemfile index 3257afb..77626ce 100644 --- a/Gemfile +++ b/Gemfile @@ -1,98 +1,98 @@ -source 'https://rubygems.org' +source "https://rubygems.org" -gem 'rails', '~> 5.2.0' -gem 'bootsnap' +gem "rails", "~> 5.2.0" +gem "bootsnap" -gem 'sqlite3' -gem 'pg' +gem "sqlite3" +gem "pg" -gem 'sass-rails' +gem "sass-rails" -gem 'uglifier' -gem 'coffee-rails' -gem 'mini_racer', platforms: :ruby -gem 'jquery-rails' +gem "uglifier" +gem "coffee-rails" +gem "mini_racer", platforms: :ruby +gem "jquery-rails" -gem 'slim-rails' +gem "slim-rails" -gem 'rails-i18n' +gem "rails-i18n" -gem 'devise' -gem 'devise-i18n' +gem "devise" +gem "devise-i18n" -gem 'simple_form' +gem "simple_form" # Phone validation -gem 'phony', '~> 2.15.11' -gem 'phony_rails' +gem "phony", "~> 2.15.11" +gem "phony_rails" # Picture uploads -gem 'carrierwave' -#gem 'rmagick' +gem "carrierwave" +# gem 'rmagick' 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 'puma', group: :production +gem "puma", group: :production -gem 'globalize' +gem "globalize" -gem 'yaml_db' +gem "yaml_db" -gem 'bootstrap-sass' -gem 'bootstrap-sass-extras' -gem 'bootswatch-rails' -gem 'autoprefixer-rails' -gem 'font-awesome-sass', '~> 4.6.2' +gem "bootstrap-sass" +gem "bootstrap-sass-extras" +gem "bootswatch-rails" +gem "autoprefixer-rails" +gem "font-awesome-sass", "~> 4.6.2" -gem 'nested_form' -gem 'jquery-datatables-rails' -gem 'morrisjs-rails' -gem 'raphael-rails' +gem "nested_form" +gem "jquery-datatables-rails" +gem "morrisjs-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 - gem 'spring' - gem 'spring-commands-rspec' - gem 'guard-rspec' # Continuous testing with Guard - gem 'rails-erd' - gem 'pry-rails' + gem "spring" + gem "spring-commands-rspec" + gem "guard-rspec" # Continuous testing with Guard + gem "rails-erd" + gem "pry-rails" # gem 'hirb' - gem 'awesome_print' - gem 'capistrano' - gem 'capistrano-rails' + gem "awesome_print" + gem "capistrano" + gem "capistrano-rails" # gem 'capistrano-rvm' - gem 'capistrano3-puma' - gem 'better_errors' - gem 'binding_of_caller' + gem "capistrano3-puma" + gem "better_errors" + gem "binding_of_caller" end group :development, :test do - gem 'rspec-rails' - gem 'factory_bot_rails' - gem 'faker' - gem 'capybara' - gem 'selenium-webdriver' + gem "rspec-rails" + gem "factory_bot_rails" + gem "faker" + gem "capybara" + gem "selenium-webdriver" - gem 'byebug' - gem 'simplecov' - gem 'i18n-tasks' + gem "byebug" + gem "simplecov" + gem "i18n-tasks" - gem 'delorean' + gem "delorean" - gem 'standard' + gem "standard" end group :test do - gem 'database_cleaner' + gem "database_cleaner" end diff --git a/Guardfile b/Guardfile index 6516f56..2c31b20 100644 --- a/Guardfile +++ b/Guardfile @@ -1,17 +1,17 @@ # 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{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } - watch('spec/rails_helper.rb') { 'spec' } + watch("spec/spec_helper.rb") { "spec" } + watch("spec/rails_helper.rb") { "spec" } 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/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('config/routes.rb') { 'spec/routing' } - watch('app/controllers/application_controller.rb') { 'spec/controllers' } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch("config/routes.rb") { "spec/routing" } + watch("app/controllers/application_controller.rb") { "spec/controllers" } # Capybara features specs watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } diff --git a/Rakefile b/Rakefile index ba6b733..1d92159 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ # 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. -require File.expand_path('../config/application', __FILE__) +require File.expand_path("../config/application", __FILE__) Rails.application.load_tasks diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a6f23b9..1d4c000 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,10 +9,10 @@ class ApplicationController < ActionController::Base before_action :set_view_paths # TODO: make this get the domain from the database - #layout Proc.new { |controller| controller.request.host } - layout 'public/application' + # layout Proc.new { |controller| controller.request.host } + layout "public/application" - def self.default_url_options(options={}) + def self.default_url_options(options = {}) if I18n.locale != I18n.default_locale options.merge({locale: I18n.locale}) else @@ -24,17 +24,16 @@ class ApplicationController < ActionController::Base def set_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) end end def set_view_paths # 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 =~ /example/ - prepend_view_path 'lib/initfest/views' if request.host =~ /127\.0\.0/ - + 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 =~ /127\.0\.0/ end protected diff --git a/app/controllers/concerns/current_conference_assigning.rb b/app/controllers/concerns/current_conference_assigning.rb index d39fbc3..0f304cb 100644 --- a/app/controllers/concerns/current_conference_assigning.rb +++ b/app/controllers/concerns/current_conference_assigning.rb @@ -11,8 +11,8 @@ module CurrentConferenceAssigning end def current_conference - if not @current_conference - if @conference and not @conference.new_record? + unless @current_conference + if @conference && !@conference.new_record? @current_conference = @conference elsif params[:conference_id].present? @current_conference = Conference.find(params[:conference_id]) @@ -23,8 +23,8 @@ module CurrentConferenceAssigning end def require_current_conference! - if not current_conference? - raise ActionController::RoutingError.new('Not Found') + unless current_conference? + raise ActionController::RoutingError.new("Not Found") end end end diff --git a/app/controllers/concerns/public_api_exposing.rb b/app/controllers/concerns/public_api_exposing.rb index 17b541e..9450a09 100644 --- a/app/controllers/concerns/public_api_exposing.rb +++ b/app/controllers/concerns/public_api_exposing.rb @@ -1,14 +1,14 @@ -require 'active_support/concern' +require "active_support/concern" module PublicApiExposing extend ActiveSupport::Concern def set_access_control_headers if request.format.json? - response.headers['Access-Control-Allow-Origin'] = '*' + response.headers["Access-Control-Allow-Origin"] = "*" end end - + included do before_action :set_access_control_headers end diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 17a4feb..1e3efc1 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -6,9 +6,9 @@ class ConfirmationsController < Devise::ConfirmationsController if resource.errors.empty? set_flash_message(:notice, :confirmed) if is_flashing_format? 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 - respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } + respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new } end end end diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index 85b4b37..f02d778 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -2,10 +2,10 @@ module Management class ConferencesController < ManagementController def new @conference = Conference.new - @conference.event_types.build(name: 'Event type 1') - @conference.tracks.build(name: 'Track 1') - @conference.halls.build(name: 'Hall 1') - @conference.volunteer_teams.build(name: 'Volunteer Team 1') + @conference.event_types.build(name: "Event type 1") + @conference.tracks.build(name: "Track 1") + @conference.halls.build(name: "Hall 1") + @conference.volunteer_teams.build(name: "Volunteer Team 1") end def create @@ -49,13 +49,13 @@ module Management begin if @conference.update_vote_data! - flash[:notice] = t('.vote_data_successfully_updated') + flash[:notice] = t(".vote_data_successfully_updated") else - flash[:alert] = t('.error_during_vote_data_save') + flash[:alert] = t(".error_during_vote_data_save") end redirect_back fallback_location: [:management, @conference] - rescue StandardError => e - flash[:alert] = t('.error_during_connection_with_voting_endpoint', error: e.message) + rescue => e + flash[:alert] = t(".error_during_connection_with_voting_endpoint", error: e.message) render :vote_results end end @@ -75,9 +75,9 @@ module Management :title, :email, :start_date, :end_date, :description, :host_name, :planned_cfp_end_date, :vote_data_endpoint, event_types_attributes: [:id, :name, :description, :maximum_length, - :minimum_length, :_destroy], + :minimum_length, :_destroy,], tracks_attributes: [:id, :name, :color, :css_class, :description, - :css_style, :foreground_color, :_destroy], + :css_style, :foreground_color, :_destroy,], halls_attributes: [:id, :name, :_destroy], volunteer_teams_attributes: [:id, :name, :description, :color, :_destroy] ) diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index 78c5d32..d0e4ea1 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -22,10 +22,10 @@ module Management @event = @conference.events.find(params[:id]) if @event.update(event_params) - flash[:notice] = t('.event_successfully_updated') + flash[:notice] = t(".event_successfully_updated") redirect_to [:management, @conference, @event] else - render action: 'edit' + render action: "edit" end end @@ -51,22 +51,22 @@ module Management def event_params params.require(:event).permit( - :title, - :subtitle, - :length, - :language, - :abstract, - :description, - :notes, - :track_id, - :event_type_id, - participations_attributes: [ - :id, - :participant_id, - :approved, - :_destroy - ] - ) + :title, + :subtitle, + :length, + :language, + :abstract, + :description, + :notes, + :track_id, + :event_type_id, + participations_attributes: [ + :id, + :participant_id, + :approved, + :_destroy, + ] + ) end end end diff --git a/app/controllers/management/management_controller.rb b/app/controllers/management/management_controller.rb index b2818be..5286684 100644 --- a/app/controllers/management/management_controller.rb +++ b/app/controllers/management/management_controller.rb @@ -1,9 +1,9 @@ -require 'csv' +require "csv" module Management class ManagementController < ::ApplicationController before_action :authenticate_user!, :authorize_user! - layout 'management' + layout "management" private diff --git a/app/controllers/management/personal_profiles_controller.rb b/app/controllers/management/personal_profiles_controller.rb index 110c14a..f32a450 100644 --- a/app/controllers/management/personal_profiles_controller.rb +++ b/app/controllers/management/personal_profiles_controller.rb @@ -18,7 +18,7 @@ module Management @profile = find_profile @user = @profile.user - if not @profile + unless @profile flash[:error] = "No profile, needs to be created" redirect_to action: :edit end @@ -36,7 +36,7 @@ module Management @profile = @user.build_personal_profile(@conference, profile_params) 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) else render action: :new @@ -56,7 +56,7 @@ module Management if @profile.update_attributes(profile_params) redirect_to [:management, @conference, @profile] else - render action: 'edit' + render action: "edit" end end diff --git a/app/controllers/management/volunteers_controller.rb b/app/controllers/management/volunteers_controller.rb index bb792c9..0ce4278 100644 --- a/app/controllers/management/volunteers_controller.rb +++ b/app/controllers/management/volunteers_controller.rb @@ -26,12 +26,13 @@ module Management end private + def volunteer_params params.require(:volunteer).permit(:name, :picture, :email, :phone, - :tshirt_size, :tshirt_cut, - :food_preferences, :previous_experience, - :notes, :language, - volunteer_team_ids: []) + :tshirt_size, :tshirt_cut, + :food_preferences, :previous_experience, + :notes, :language, + volunteer_team_ids: []) end end end diff --git a/app/controllers/public/conference_feedbacks_controller.rb b/app/controllers/public/conference_feedbacks_controller.rb index e412f3b..486dec6 100644 --- a/app/controllers/public/conference_feedbacks_controller.rb +++ b/app/controllers/public/conference_feedbacks_controller.rb @@ -2,15 +2,14 @@ class Public::ConferenceFeedbacksController < Public::ApplicationController def index @conference = current_conference @unrated_events = @conference.events - .joins(:proposition).approved - .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 + .joins(:proposition).approved + .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 @rated_events = @conference.events - .joins(:proposition).approved - .joins(:feedbacks) - .where(feedbacks: {session_id: session.id}).distinct - + .joins(:proposition).approved + .joins(:feedbacks) + .where(feedbacks: {session_id: session.id}).distinct end def new @@ -28,7 +27,7 @@ class Public::ConferenceFeedbacksController < Public::ApplicationController @feedback.session_id = session.id 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 else render :new, status: :unprocessable_entity diff --git a/app/controllers/public/event_feedback_qrcodes_controller.rb b/app/controllers/public/event_feedback_qrcodes_controller.rb index 2ec1ae1..5d2586d 100644 --- a/app/controllers/public/event_feedback_qrcodes_controller.rb +++ b/app/controllers/public/event_feedback_qrcodes_controller.rb @@ -5,7 +5,7 @@ class Public::EventFeedbackQrcodesController < Public::ApplicationController respond_to do |format| 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") end end diff --git a/app/controllers/public/event_feedbacks_controller.rb b/app/controllers/public/event_feedbacks_controller.rb index fab2938..2b7bd16 100644 --- a/app/controllers/public/event_feedbacks_controller.rb +++ b/app/controllers/public/event_feedbacks_controller.rb @@ -14,7 +14,7 @@ class Public::EventFeedbacksController < Public::ApplicationController @feedback.session_id = session.id 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 else render :new, status: :unprocessable_entity diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb index fc24a94..4cd4147 100644 --- a/app/controllers/public/events_controller.rb +++ b/app/controllers/public/events_controller.rb @@ -3,7 +3,7 @@ module Public before_action :authenticate_user! 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 def edit @@ -22,7 +22,7 @@ module Public @event.participations.build participant: current_user, approved: true 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 else render action: :new @@ -33,7 +33,7 @@ module Public @event = Event.joins(:participations).find_by(id: params[:id], participations: {participant_id: current_user.id}) 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 else render action: :edit @@ -44,9 +44,9 @@ module Public @event = current_user.events.approved.find(params[:id]) 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 - 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 after_save_redirect diff --git a/app/controllers/public/personal_profiles_controller.rb b/app/controllers/public/personal_profiles_controller.rb index 6c5c85b..1aff08b 100644 --- a/app/controllers/public/personal_profiles_controller.rb +++ b/app/controllers/public/personal_profiles_controller.rb @@ -6,7 +6,7 @@ module Public @profile = current_user.build_personal_profile(current_conference, profile_params) if @profile.save - flash[:notice] = t('views.personal_profiles.successfully_created') + flash[:notice] = t("views.personal_profiles.successfully_created") redirect_to root_path else render action: :new @@ -21,10 +21,10 @@ module Public @profile = current_user.personal_profile(current_conference) 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 else - render action: 'edit' + render action: "edit" end end diff --git a/app/controllers/public/volunteers_controller.rb b/app/controllers/public/volunteers_controller.rb index 303b188..249645d 100644 --- a/app/controllers/public/volunteers_controller.rb +++ b/app/controllers/public/volunteers_controller.rb @@ -11,7 +11,7 @@ module Public def create @volunteer = current_conference.volunteers.build volunteer_params 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) else render :new, status: :unprocessable_entity @@ -21,7 +21,7 @@ module Public def update @volunteer = current_conference.volunteers.find_by! unique_id: params[:id] 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) else render :edit, status: :unprocessable_entity diff --git a/app/controllers/public/volunteerships_controller.rb b/app/controllers/public/volunteerships_controller.rb index 119e09e..bb7292c 100644 --- a/app/controllers/public/volunteerships_controller.rb +++ b/app/controllers/public/volunteerships_controller.rb @@ -12,9 +12,9 @@ module Public @volunteership.build_proposition proposer: current_user, status: :undecided 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 - flash[:error] = I18n.t('views.volunteerships.an error_occurred_while_applying') + flash[:error] = I18n.t("views.volunteerships.an error_occurred_while_applying") end after_save_redirect @@ -24,7 +24,7 @@ module Public @volunteership = current_user.volunteerships.find params[:id] 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 redirect_to volunteerships_path diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 66bf903..80e407a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,7 +10,7 @@ module ApplicationHelper "undecided" => "default", "approved" => "info", "rejected" => "danger", - "backup" => "warning" + "backup" => "warning", }.with_indifferent_access[status] end @@ -19,7 +19,7 @@ module ApplicationHelper "undecided" => "question", "approved" => "thumbs-up", "rejected" => "thumbs-down", - "backup" => "refresh" + "backup" => "refresh", }.with_indifferent_access[status] end @@ -29,36 +29,36 @@ module ApplicationHelper def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy]) klass = record.class - output = '' + output = "" if actions.include? :index output += link_to(icon(:list), [:management, conference, klass], { - title: t('actions.index.button', models: klass.model_name.human(count: 2)), - class: 'btn btn-info' + title: t("actions.index.button", models: klass.model_name.human(count: 2)), + class: "btn btn-info", }) end if actions.include? :show output += link_to(icon(:eye), [:management, conference, record], { - title: t('actions.view.button', model: klass.model_name.human), - class: 'btn btn-info' + title: t("actions.view.button", model: klass.model_name.human), + class: "btn btn-info", }) end if actions.include? :edit - output += link_to(icon(:edit), [:edit, :management, conference, record], { - title: t('actions.edit.button', model: klass.model_name.human), - class: 'btn btn-warning' - }) + output += link_to(icon(:edit), [:edit, :management, conference, record], { + title: t("actions.edit.button", model: klass.model_name.human), + class: "btn btn-warning", + }) end if actions.include? :destroy - output += link_to(icon(:trash), [:management, conference, record], { - method: :delete, - data: {confirm: t('actions.are_you_sure')}, - title: t('actions.destroy.button', model: klass.model_name.human), - class: 'btn btn-danger' - }) + output += link_to(icon(:trash), [:management, conference, record], { + method: :delete, + data: {confirm: t("actions.are_you_sure")}, + title: t("actions.destroy.button", model: klass.model_name.human), + class: "btn btn-danger", + }) end output.html_safe diff --git a/app/helpers/conferences_helper.rb b/app/helpers/conferences_helper.rb index 9b22a0e..c7e067d 100644 --- a/app/helpers/conferences_helper.rb +++ b/app/helpers/conferences_helper.rb @@ -5,26 +5,26 @@ module ConferencesHelper 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 - chart_data = (start_date..end_date).map do |date| + chart_data = (start_date..end_date).map { |date| { created_at: date, 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| entry[:all_submissions] = if index == 0 - entry[:new_submissions] - else - chart_data[index - 1][:all_submissions] + entry[:new_submissions] - end + entry[:new_submissions] + else + chart_data[index - 1][:all_submissions] + entry[:new_submissions] + end entry[:all_confirmations] = if index == 0 - entry[:new_confirmations] - else - chart_data[index - 1][:all_confirmations] + entry[:new_confirmations] - end + entry[:new_confirmations] + else + chart_data[index - 1][:all_confirmations] + entry[:new_confirmations] + end end chart_data end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 815fc65..2ea8258 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,16 +1,16 @@ module EventsHelper 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? link_to icon(:user, participant.name), management_conference_personal_profile_path(participant.personal_profile_id, conference_id: event.conference.id) 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, 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.join(', ').html_safe + }.join(", ").html_safe end def participant_names_with_emails(event) @@ -25,13 +25,11 @@ module EventsHelper end def participant_names(event) - event.participants.map do |participant| + event.participants.map { |participant| if participant.personal_profile(event.conference).present? profile = participant.personal_profile(event.conference) - "#{profile.name}" - else - nil + profile.name.to_s end - end.compact + }.compact end end diff --git a/app/mailers/event_mailer.rb b/app/mailers/event_mailer.rb index 8b3d3a1..3df9c14 100644 --- a/app/mailers/event_mailer.rb +++ b/app/mailers/event_mailer.rb @@ -1,15 +1,14 @@ -# coding: utf-8 class EventMailer < ActionMailer::Base def confirmation_request(event) @event = event I18n.locale = @event.proposer.language mail to: @event.proposer.email, - from: 'program@openfest.org', - subject: I18n.t('event_mailer.acceptance_notification.subject', - conference: @event.conference.title, - submission_type: @event.event_type.name.mb_chars.downcase.to_s, - title: @event.title) + from: "program@openfest.org", + subject: I18n.t("event_mailer.acceptance_notification.subject", + conference: @event.conference.title, + submission_type: @event.event_type.name.mb_chars.downcase.to_s, + title: @event.title) end def rejection_notification(event) @@ -17,11 +16,10 @@ class EventMailer < ActionMailer::Base I18n.locale = @event.proposer.language mail to: @event.proposer.email, - from: 'program@openfest.org', - subject: I18n.t('event_mailer.rejection_notification.subject', - conference: @event.conference.title, - submission_type: @event.event_type.name.mb_chars.downcase.to_s, - title: @event.title) + from: "program@openfest.org", + subject: I18n.t("event_mailer.rejection_notification.subject", + conference: @event.conference.title, + submission_type: @event.event_type.name.mb_chars.downcase.to_s, + title: @event.title) end - end diff --git a/app/mailers/proposition_mailer.rb b/app/mailers/proposition_mailer.rb index 07829f3..b9080cf 100644 --- a/app/mailers/proposition_mailer.rb +++ b/app/mailers/proposition_mailer.rb @@ -1,4 +1,3 @@ -# coding: utf-8 class PropositionMailer < ActionMailer::Base def new_proposition_notification(proposition) @proposition = proposition diff --git a/app/mailers/volunteer_mailer.rb b/app/mailers/volunteer_mailer.rb index d30a5fc..e526ff0 100644 --- a/app/mailers/volunteer_mailer.rb +++ b/app/mailers/volunteer_mailer.rb @@ -1,10 +1,9 @@ -# coding: utf-8 class VolunteerMailer < ActionMailer::Base def team_notification(new_volunteer) @volunteer = new_volunteer 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 def volunteer_notification(new_volunteer) @@ -12,8 +11,8 @@ class VolunteerMailer < ActionMailer::Base I18n.locale = @volunteer.language mail(to: @volunteer.email, reply_to: @volunteer.conference.email, - from: 'no-reply@openfest.org', - subject: I18n.t('volunteer_mailer.success_notification.subject', - conference_name: @volunteer.conference.title)) + from: "no-reply@openfest.org", + subject: I18n.t("volunteer_mailer.success_notification.subject", + conference_name: @volunteer.conference.title)) end end diff --git a/app/models/call_for_participation.rb b/app/models/call_for_participation.rb index 2011576..ce81973 100644 --- a/app/models/call_for_participation.rb +++ b/app/models/call_for_participation.rb @@ -2,7 +2,7 @@ class CallForParticipation < ActiveRecord::Base belongs_to :conference 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 save end @@ -13,14 +13,14 @@ class CallForParticipation < ActiveRecord::Base end def open? - self.opens_at.present? and self.opens_at < Time.now + opens_at.present? && (opens_at < Time.now) end def closed? - self.closes_at.present? and self.closes_at < Time.now + closes_at.present? && (closes_at < Time.now) end def in_progress? - open? and not closed? + open? && !closed? end end diff --git a/app/models/conference.rb b/app/models/conference.rb index 02a7a0a..49abb8e 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -14,30 +14,30 @@ class Conference < ActiveRecord::Base has_many :halls has_many :event_types 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 :volunteer_teams has_many :volunteers has_one :call_for_participation - has_many :participants, -> { distinct }, class_name: 'User', through: :events - has_many :participant_profiles, class_name: 'PersonalProfile' + has_many :participants, -> { distinct }, class_name: "User", through: :events + has_many :participant_profiles, class_name: "PersonalProfile" has_many :slots, through: :halls 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 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 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 } end 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 } end @@ -46,7 +46,7 @@ class Conference < ActiveRecord::Base end 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 def has_voting_endpoint? @@ -54,8 +54,8 @@ class Conference < ActiveRecord::Base end def update_conflict_data! - update_vote_data! or raise ActiveRecord::Rollback - events.all? { |event| event.update_conflict_data(false) } or raise ActiveRecord::Rollback + update_vote_data! || raise(ActiveRecord::Rollback) + events.all? { |event| event.update_conflict_data(false) } || raise(ActiveRecord::Rollback) end 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 end - private 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) end end 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) end end @@ -95,38 +94,38 @@ class Conference < ActiveRecord::Base attr_accessor :conference def number_of_ballots - @number_of_ballots ||= remote_summary_data['number_of_ballots'] + @number_of_ballots ||= remote_summary_data["number_of_ballots"] end 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 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 def save conference.transaction do conference.number_of_ballots_cast = number_of_ballots - conflicts.all?(&:save) or raise ActiveRecord::Rollback - ranking.all?(&:save) or raise ActiveRecord::Rollback + conflicts.all?(&:save) || raise(ActiveRecord::Rollback) + ranking.all?(&:save) || raise(ActiveRecord::Rollback) conference.touch :vote_data_updated_at - conference.save or raise ActiveRecord::Rollback + conference.save || raise(ActiveRecord::Rollback) end end private def connection - @connection ||= Faraday.new(url: conference.vote_data_endpoint + '/summary.json', - headers: {'Content-Type' => 'application/json'}) + @connection ||= Faraday.new(url: conference.vote_data_endpoint + "/summary.json", + headers: {"Content-Type" => "application/json"}) end 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 - end.body) + }.body) end class ConflictsForEvent @@ -136,14 +135,13 @@ class Conference < ActiveRecord::Base def save @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| 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 - class EventRanking include ActiveModel::Model diff --git a/app/models/conflict_count.rb b/app/models/conflict_count.rb index abd3eeb..c954adc 100644 --- a/app/models/conflict_count.rb +++ b/app/models/conflict_count.rb @@ -1,5 +1,5 @@ class ConflictCount < ActiveRecord::Base - belongs_to :left, class_name: 'Event' - belongs_to :right, class_name: 'Event' + belongs_to :left, class_name: "Event" + belongs_to :right, class_name: "Event" has_one :conference, through: :left end diff --git a/app/models/event.rb b/app/models/event.rb index e7cbc52..bba82f9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -6,8 +6,8 @@ class Event < ActiveRecord::Base has_one :slot has_many :participations, dependent: :destroy - has_many :pending_participations, ->() { pending }, class_name: 'Participation' - has_many :approved_participations, ->() { approved }, class_name: 'Participation' + has_many :pending_participations, -> { pending }, class_name: "Participation" + has_many :approved_participations, -> { approved }, class_name: "Participation" has_many :participants, through: :approved_participations 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 @@ -19,7 +19,7 @@ class Event < ActiveRecord::Base scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})} validates :conference, presence: true - validates :title, presence: true, length: { maximum: 65 } + validates :title, presence: true, length: {maximum: 65} validates :abstract, presence: true validates :description, presence: true validates :agreement, acceptance: true @@ -61,16 +61,16 @@ class Event < ActiveRecord::Base language: language, abstract: abstract, description: description, - notes: notes + notes: notes, } end 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 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) else Float::NAN @@ -80,20 +80,20 @@ class Event < ActiveRecord::Base private 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 end end 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 end end def length_is_within_the_permitted_interval 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 end end diff --git a/app/models/event_search.rb b/app/models/event_search.rb index 6c0632d..0973f6d 100644 --- a/app/models/event_search.rb +++ b/app/models/event_search.rb @@ -9,6 +9,6 @@ class EventSearch 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}) } - sort_by 'title' - config[:defaults]['sort'] = "#{config[:sort_attributes].first} asc" + sort_by "title" + config[:defaults]["sort"] = "#{config[:sort_attributes].first} asc" end diff --git a/app/models/feedback.rb b/app/models/feedback.rb index 37517db..af217bf 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -1,7 +1,7 @@ class Feedback < ActiveRecord::Base 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 diff --git a/app/models/participant.rb b/app/models/participant.rb index 8284739..beea7d8 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -3,7 +3,7 @@ class Participant < ActiveRecord::Base self.primary_key = :participant_id def twitter=(handle) - write_attribute :twitter, handle.gsub(/\A@/,'') if handle + write_attribute :twitter, handle.gsub(/\A@/, "") if handle end def name diff --git a/app/models/participation.rb b/app/models/participation.rb index bfd700e..2b43099 100644 --- a/app/models/participation.rb +++ b/app/models/participation.rb @@ -1,8 +1,8 @@ class Participation < ActiveRecord::Base - belongs_to :participant, class_name: 'User' - has_one :participant_with_personal_profile, class_name: 'Participant' + belongs_to :participant, class_name: "User" + has_one :participant_with_personal_profile, class_name: "Participant" belongs_to :event validates :participant_id, presence: true - scope :approved, ->() { where approved: true } - scope :pending, ->() { where.not approved: true } + scope :approved, -> { where approved: true } + scope :pending, -> { where.not approved: true } end diff --git a/app/models/personal_profile.rb b/app/models/personal_profile.rb index f513571..68a30ef 100644 --- a/app/models/personal_profile.rb +++ b/app/models/personal_profile.rb @@ -11,14 +11,14 @@ class PersonalProfile < ActiveRecord::Base 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 - 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 accepts_nested_attributes_for :user def twitter=(handle) - write_attribute :twitter, handle.gsub(/\A@/,'') if handle + write_attribute :twitter, handle.gsub(/\A@/, "") if handle end def name diff --git a/app/models/proposition.rb b/app/models/proposition.rb index 0fd16f2..2a917c2 100644 --- a/app/models/proposition.rb +++ b/app/models/proposition.rb @@ -1,5 +1,5 @@ class Proposition < ActiveRecord::Base - belongs_to :proposer, class_name: 'User' + belongs_to :proposer, class_name: "User" belongs_to :proposable, polymorphic: true, dependent: :destroy enum status: [:undecided, :approved, :rejected, :backup] delegate :proposable_title, :proposable_type, :proposable_description, to: :proposable diff --git a/app/models/track.rb b/app/models/track.rb index f33bb85..53ce95e 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -9,7 +9,7 @@ class Track < ActiveRecord::Base translates :name, :description 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 def color diff --git a/app/models/user.rb b/app/models/user.rb index 6734fe3..b27f8ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,13 +2,13 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :confirmable, - :recoverable, :rememberable, :trackable, :validatable + :recoverable, :rememberable, :trackable, :validatable has_many :personal_profiles, dependent: :destroy has_many :lectures has_many :workshops 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 :events_participated_in, through: :participations, source: :event has_many :volunteerships, foreign_key: :volunteer_id diff --git a/app/models/volunteer.rb b/app/models/volunteer.rb index da33cb6..e3a4ac1 100644 --- a/app/models/volunteer.rb +++ b/app/models/volunteer.rb @@ -14,7 +14,7 @@ class Volunteer < ActiveRecord::Base validates :volunteer_teams, presence: true validate :volunteer_teams_belong_to_conference - phony_normalize :phone, default_country_code: 'BG' + phony_normalize :phone, default_country_code: "BG" belongs_to :conference has_and_belongs_to_many :volunteer_teams diff --git a/app/models/volunteer_search.rb b/app/models/volunteer_search.rb index 5f34076..11af181 100644 --- a/app/models/volunteer_search.rb +++ b/app/models/volunteer_search.rb @@ -3,6 +3,6 @@ class VolunteerSearch option(:volunteer_team_id) { |scope, value| scope.joins(:volunteer_teams).where volunteer_teams: {id: value} } - sort_by 'name' - config[:defaults]['sort'] = "#{config[:sort_attributes].first} asc" + sort_by "name" + config[:defaults]["sort"] = "#{config[:sort_attributes].first} asc" end diff --git a/app/models/volunteer_team.rb b/app/models/volunteer_team.rb index 5c5c2f7..4105cee 100644 --- a/app/models/volunteer_team.rb +++ b/app/models/volunteer_team.rb @@ -13,7 +13,7 @@ class VolunteerTeam < ActiveRecord::Base end 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 def color diff --git a/app/models/volunteership.rb b/app/models/volunteership.rb index ce03c1a..92092ed 100644 --- a/app/models/volunteership.rb +++ b/app/models/volunteership.rb @@ -2,7 +2,7 @@ class Volunteership < ActiveRecord::Base include Proposable belongs_to :volunteer_team - belongs_to :volunteer, class_name: 'User' + belongs_to :volunteer, class_name: "User" has_one :conference, through: :volunteer_team def proposable_title diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index 55deef0..707e7e1 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -1,7 +1,6 @@ class PictureUploader < CarrierWave::Uploader::Base - # Include RMagick or MiniMagick support: - #include CarrierWave::RMagick + # include CarrierWave::RMagick include CarrierWave::MiniMagick # 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: 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 # Process files as they are uploaded: @@ -29,21 +28,21 @@ class PictureUploader < CarrierWave::Uploader::Base # Create different versions of your uploaded files: version :medium do - process :resize_to_fit => [171, 180] + process resize_to_fit: [171, 180] end version :thumb do - process :resize_to_fit => [50, 50] + process resize_to_fit: [50, 50] end version :schedule do - process :resize_to_fill => [100, 100] + process resize_to_fill: [100, 100] end # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg png) + %w[jpg jpeg png] end # Override the filename of the uploaded files: @@ -51,5 +50,4 @@ class PictureUploader < CarrierWave::Uploader::Base # def filename # "something.jpg" if original_filename # end - end diff --git a/config.ru b/config.ru index 5bc2a61..193e5fe 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # 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 diff --git a/config/application.rb b/config/application.rb index 5a98e13..8796786 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 # 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. # 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. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] @@ -29,12 +29,12 @@ module Clarion config.generators do |g| g.test_framework :rspec, fixtures: true, - view_specs: false, - helper_specs: false, - routing_specs: false, - request_specs: false + view_specs: false, + helper_specs: false, + routing_specs: false, + request_specs: false - g.fixture_replacement :factory_bot, dir: 'spec/factories' + g.fixture_replacement :factory_bot, dir: "spec/factories" end end end diff --git a/config/boot.rb b/config/boot.rb index b9e460c..988a5dd 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -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 'bootsnap/setup' # Speed up boot time by caching expensive operations. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/deploy.rb b/config/deploy.rb index 8ad974c..f6be4ce 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,14 +1,14 @@ # config valid only for current version of Capistrano -lock '3.11.0' +lock "3.11.0" -set :application, 'clarion' -set :repo_url, 'https://github.com/ignisf/clarion.git' +set :application, "clarion" +set :repo_url, "https://github.com/ignisf/clarion.git" # Default branch is :master ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # 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 # set :scm, :git @@ -23,10 +23,10 @@ set :deploy_to, '/home/barf/clarion' # set :pty, true # 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 [] -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 {} # 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 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_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_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_server_name, 'cfp.openfest.org' +set :nginx_server_name, "cfp.openfest.org" namespace :deploy do - after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: diff --git a/config/deploy/production.rb b/config/deploy/production.rb index b1277f3..b0fae91 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -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 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 # ================== @@ -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 :db, %w{deploy@example.com} - - # Configuration # ============= # 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/ # Feel free to add new variables to customise your setup. - - # Custom SSH Options # ================== # 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 # -------------- set :ssh_options, { -# keys: %w(/home/rlisowski/.ssh/id_rsa), - forward_agent: true, -# auth_methods: %w(password) + # keys: %w(/home/rlisowski/.ssh/id_rsa), + forward_agent: true, + # auth_methods: %w(password) } # # The server-based syntax can be used to override options: diff --git a/config/environment.rb b/config/environment.rb index 426333b..cac5315 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 2eb50ce..9841058 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -14,12 +14,12 @@ Rails.application.configure do # Enable/disable caching. By default caching is disabled. # 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.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}", } else config.action_controller.perform_caching = false @@ -34,8 +34,8 @@ Rails.application.configure do config.action_mailer.raise_delivery_errors = false # Use localhost for default host - config.action_mailer.default_url_options = {host: 'localhost:3000'} - config.action_mailer.default_options = {from: 'no-reply@example.com'} + config.action_mailer.default_url_options = {host: "localhost:3000"} + config.action_mailer.default_options = {from: "no-reply@example.com"} config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. diff --git a/config/environments/production.rb b/config/environments/production.rb index 436cb04..6c6fb2d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,7 +20,7 @@ Rails.application.configure do # Disable serving static files from the `/public` folder by default since # 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. config.assets.js_compressor = :uglifier @@ -54,7 +54,7 @@ Rails.application.configure do config.log_level = :debug # 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. # config.cache_store = :mem_cache_store @@ -70,8 +70,8 @@ Rails.application.configure do # config.action_mailer.raise_delivery_errors = false config.action_mailer.delivery_method = :sendmail - config.action_mailer.default_options = {from: 'no-reply@openfest.org'} - config.action_mailer.default_url_options = {host: 'cfp.openfest.org'} + config.action_mailer.default_options = {from: "no-reply@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 # the I18n.default_locale when a translation cannot be found). diff --git a/config/environments/test.rb b/config/environments/test.rb index eda59e7..d2851b7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,7 +15,7 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true 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. @@ -39,8 +39,8 @@ Rails.application.configure do config.action_mailer.delivery_method = :test # Use localhost for default host - config.action_mailer.default_url_options = {host: 'localhost:3000'} - config.action_mailer.default_options = {from: 'no-reply@example.com'} + config.action_mailer.default_url_options = {host: "localhost:3000"} + config.action_mailer.default_options = {from: "no-reply@example.com"} # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 390b765..7b3fd91 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,19 +1,19 @@ # 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. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_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/javascripts' -Rails.application.config.assets.paths << 'lib/initfest/assets/stylesheets' +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/stylesheets" Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # 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] diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 9b85273..1c7475b 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -12,7 +12,7 @@ Devise.setup do |config| # 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 # 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. # config.mailer = 'Devise::Mailer' @@ -21,7 +21,7 @@ Devise.setup do |config| # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. - require 'devise/orm/active_record' + require "devise/orm/active_record" # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index eda06fa..5c534a9 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # 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" diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index d5492e5..e7f43e0 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -6,7 +6,7 @@ SimpleForm.setup do |config| # stack. The options given below are used to wrap the # whole 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 # Any of these extensions can be disabled for a # given input by passing: `f.input EXTENSION_NAME => false`. @@ -41,8 +41,8 @@ SimpleForm.setup do |config| ## Inputs b.use :label_input - b.use :hint, wrap_with: { tag: :span, class: :hint } - b.use :error, wrap_with: { tag: :span, class: :error } + b.use :hint, wrap_with: {tag: :span, class: :hint} + b.use :error, wrap_with: {tag: :span, class: :error} ## full_messages_for # 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 # Default class for buttons - config.button_class = 'btn' + config.button_class = "btn" # Method used to tidy up errors. Specify any Rails Array method. # :first lists the first message for each field. @@ -72,7 +72,7 @@ SimpleForm.setup do |config| config.error_notification_tag = :div # 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. # config.error_notification_id = nil @@ -155,7 +155,7 @@ SimpleForm.setup do |config| # config.input_class = nil # 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 # collection wrappers. diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb index ea4a63d..04e5d8a 100644 --- a/config/initializers/simple_form_bootstrap.rb +++ b/config/initializers/simple_form_bootstrap.rb @@ -1,125 +1,125 @@ # Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| - config.error_notification_class = 'alert alert-danger' - config.button_class = 'btn btn-default' + config.error_notification_class = "alert alert-danger" + config.button_class = "btn btn-default" 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 :placeholder b.optional :maxlength b.optional :pattern b.optional :min_max b.optional :readonly - b.use :label, class: 'control-label' + b.use :label, class: "control-label" - b.use :input, class: 'form-control' - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.use :input, class: "form-control" + b.use :error, wrap_with: {tag: "span", class: "help-block"} + b.use :hint, wrap_with: {tag: "p", class: "help-block"} 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 :placeholder b.optional :maxlength b.optional :readonly - b.use :label, class: 'control-label' + b.use :label, class: "control-label" b.use :input - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.use :error, wrap_with: {tag: "span", class: "help-block"} + b.use :hint, wrap_with: {tag: "p", class: "help-block"} 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.optional :readonly - b.wrapper tag: 'div', class: 'checkbox' do |ba| + b.wrapper tag: "div", class: "checkbox" do |ba| ba.use :label_input end - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.use :error, wrap_with: {tag: "span", class: "help-block"} + b.use :hint, wrap_with: {tag: "p", class: "help-block"} 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.optional :readonly - b.use :label, class: 'control-label' + b.use :label, class: "control-label" b.use :input - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.use :error, wrap_with: {tag: "span", class: "help-block"} + b.use :hint, wrap_with: {tag: "p", class: "help-block"} 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 :placeholder b.optional :maxlength b.optional :pattern b.optional :min_max 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| - ba.use :input, class: 'form-control' - ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.wrapper tag: "div", class: "col-sm-9" do |ba| + ba.use :input, class: "form-control" + ba.use :error, wrap_with: {tag: "span", class: "help-block"} + ba.use :hint, wrap_with: {tag: "p", class: "help-block"} 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 :placeholder b.optional :maxlength 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 :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + ba.use :error, wrap_with: {tag: "span", class: "help-block"} + ba.use :hint, wrap_with: {tag: "p", class: "help-block"} 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.optional :readonly - b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| - wr.wrapper tag: 'div', class: 'checkbox' do |ba| - ba.use :label_input, class: 'col-sm-9' + b.wrapper tag: "div", class: "col-sm-offset-3 col-sm-9" do |wr| + wr.wrapper tag: "div", class: "checkbox" do |ba| + ba.use :label_input, class: "col-sm-9" end - wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } - wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + wr.use :error, wrap_with: {tag: "span", class: "help-block"} + wr.use :hint, wrap_with: {tag: "p", class: "help-block"} 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.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 :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + ba.use :error, wrap_with: {tag: "span", class: "help-block"} + ba.use :hint, wrap_with: {tag: "p", class: "help-block"} 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 :placeholder b.optional :maxlength b.optional :pattern b.optional :min_max b.optional :readonly - b.use :label, class: 'sr-only' + b.use :label, class: "sr-only" - b.use :input, class: 'form-control' - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + b.use :input, class: "form-control" + b.use :error, wrap_with: {tag: "span", class: "help-block"} + b.use :hint, wrap_with: {tag: "p", class: "help-block"} end # Wrappers for forms and inputs using the Bootstrap toolkit. diff --git a/config/routes.rb b/config/routes.rb index 56de69a..a414264 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,19 +1,19 @@ 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 - root to: 'home#index' - resource :personal_profile, path: 'profile' + root to: "home#index" + resource :personal_profile, path: "profile" resources :events do - resources :feedback, controller: 'event_feedbacks', only: [:new, :create] - resource :feedback_qr_code, controller: 'event_feedback_qrcodes', only: :show + resources :feedback, controller: "event_feedbacks", only: [:new, :create] + resource :feedback_qr_code, controller: "event_feedback_qrcodes", only: :show member do get :confirm end end resources :volunteers 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 namespace :api do @@ -33,7 +33,7 @@ Rails.application.routes.draw do end namespace :management do - root to: 'conferences#index' + root to: "conferences#index" resources :conferences do member do diff --git a/config/spring.rb b/config/spring.rb index c9119b4..9fa7863 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,6 @@ -%w( +%w[ .ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt -).each { |path| Spring.watch(path) } +].each { |path| Spring.watch(path) } diff --git a/db/migrate/20140728105159_devise_create_users.rb b/db/migrate/20140728105159_devise_create_users.rb index 71debfd..6003bd1 100644 --- a/db/migrate/20140728105159_devise_create_users.rb +++ b/db/migrate/20140728105159_devise_create_users.rb @@ -33,7 +33,7 @@ class DeviseCreateUsers < ActiveRecord::Migration[4.2] t.string :first_name, null: false t.string :last_name, null: false 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 :mobile_phone, null: false t.text :biography diff --git a/db/migrate/20140810174338_create_events.rb b/db/migrate/20140810174338_create_events.rb index 94304df..ebb7cf5 100644 --- a/db/migrate/20140810174338_create_events.rb +++ b/db/migrate/20140810174338_create_events.rb @@ -5,7 +5,7 @@ class CreateEvents < ActiveRecord::Migration[4.2] t.string :subtitle t.string :type 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.text :abstract, null: false t.text :description, null: false diff --git a/db/migrate/20140901103859_add_translation_tables_to_conferences.rb b/db/migrate/20140901103859_add_translation_tables_to_conferences.rb index ab2dcbe..1708629 100644 --- a/db/migrate/20140901103859_add_translation_tables_to_conferences.rb +++ b/db/migrate/20140901103859_add_translation_tables_to_conferences.rb @@ -1,14 +1,14 @@ class AddTranslationTablesToConferences < ActiveRecord::Migration[4.2] def up Conference.create_translation_table!({ - :title => :string, - :description => :text - }, { - :migrate_data => true - }) + title: :string, + description: :text, + }, { + migrate_data: true, + }) end def down - Conference.drop_translation_table! :migrate_data => true + Conference.drop_translation_table! migrate_data: true end end diff --git a/db/migrate/20140906151433_add_translation_tables_to_tracks.rb b/db/migrate/20140906151433_add_translation_tables_to_tracks.rb index afbb5cd..e8efcde 100644 --- a/db/migrate/20140906151433_add_translation_tables_to_tracks.rb +++ b/db/migrate/20140906151433_add_translation_tables_to_tracks.rb @@ -1,11 +1,11 @@ class AddTranslationTablesToTracks < ActiveRecord::Migration[4.2] def up Track.create_translation_table!({ - name: :string, - description: :text - }, { - migrate_data: true - }) + name: :string, + description: :text, + }, { + migrate_data: true, + }) end def down diff --git a/db/migrate/20141010142514_change_event_state_defaults.rb b/db/migrate/20141010142514_change_event_state_defaults.rb index 82476ce..926d490 100644 --- a/db/migrate/20141010142514_change_event_state_defaults.rb +++ b/db/migrate/20141010142514_change_event_state_defaults.rb @@ -1,6 +1,6 @@ class ChangeEventStateDefaults < ActiveRecord::Migration[4.2] def up - execute 'UPDATE events SET state = 0' + execute "UPDATE events SET state = 0" change_column :events, :state, :integer, null: false, default: 0 end diff --git a/db/migrate/20141105100105_create_propositions.rb b/db/migrate/20141105100105_create_propositions.rb index 27db085..bbaf339 100644 --- a/db/migrate/20141105100105_create_propositions.rb +++ b/db/migrate/20141105100105_create_propositions.rb @@ -3,7 +3,7 @@ class CreatePropositions < ActiveRecord::Migration[4.2] create_table :propositions do |t| t.references :proposer, index: 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.integer :status diff --git a/db/migrate/20141105100827_create_propositions_for_existing_events.rb b/db/migrate/20141105100827_create_propositions_for_existing_events.rb index 2f25b13..fd3c5a1 100644 --- a/db/migrate/20141105100827_create_propositions_for_existing_events.rb +++ b/db/migrate/20141105100827_create_propositions_for_existing_events.rb @@ -1,15 +1,15 @@ class CreatePropositionsForExistingEvents < ActiveRecord::Migration[4.2] def up - events = execute 'SELECT * FROM events' + events = execute "SELECT * FROM events" 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) - 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 def down - 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'" + 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'" end end diff --git a/db/migrate/20150416234411_create_event_types_for_all_existing_events.rb b/db/migrate/20150416234411_create_event_types_for_all_existing_events.rb index 467e24a..656dfb6 100644 --- a/db/migrate/20150416234411_create_event_types_for_all_existing_events.rb +++ b/db/migrate/20150416234411_create_event_types_for_all_existing_events.rb @@ -9,10 +9,10 @@ class CreateEventTypesForAllExistingEvents < ActiveRecord::Migration[4.2] GROUP BY type_name, tracks.conference_id;' 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) - 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 diff --git a/db/migrate/20150417002233_populate_event_type_of_existing_events.rb b/db/migrate/20150417002233_populate_event_type_of_existing_events.rb index de1f6e2..27d6a30 100644 --- a/db/migrate/20150417002233_populate_event_type_of_existing_events.rb +++ b/db/migrate/20150417002233_populate_event_type_of_existing_events.rb @@ -1,14 +1,14 @@ class PopulateEventTypeOfExistingEvents < ActiveRecord::Migration[4.2] 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_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}"); + 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}") end end def down - execute("UPDATE events SET event_type_id = NULL"); + execute("UPDATE events SET event_type_id = NULL") end end diff --git a/db/migrate/20150729135818_create_participation_records.rb b/db/migrate/20150729135818_create_participation_records.rb index 262c35c..74d8c1b 100644 --- a/db/migrate/20150729135818_create_participation_records.rb +++ b/db/migrate/20150729135818_create_participation_records.rb @@ -3,13 +3,13 @@ class PersonalProfile < ActiveRecord::Base; end class CreateParticipationRecords < ActiveRecord::Migration[4.2] 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| - profile = PersonalProfile.find_by(id: event_to_speaker_profile['speaker_profile_id']) - next if not profile + profile = PersonalProfile.find_by(id: event_to_speaker_profile["speaker_profile_id"]) + 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, approved: true end diff --git a/db/migrate/20151020071227_add_translations_to_halls.rb b/db/migrate/20151020071227_add_translations_to_halls.rb index 4523ad5..17da62c 100644 --- a/db/migrate/20151020071227_add_translations_to_halls.rb +++ b/db/migrate/20151020071227_add_translations_to_halls.rb @@ -1,13 +1,13 @@ class AddTranslationsToHalls < ActiveRecord::Migration[4.2] def self.up Hall.create_translation_table!({ - :name => :string + name: :string, }, { - :migrate_data => true + migrate_data: true, }) end def self.down - Hall.drop_translation_table! :migrate_data => true + Hall.drop_translation_table! migrate_data: true end end diff --git a/db/migrate/20151021183039_create_join_table_volunteer_volunteer_team.rb b/db/migrate/20151021183039_create_join_table_volunteer_volunteer_team.rb index dee31ed..b4932a7 100644 --- a/db/migrate/20151021183039_create_join_table_volunteer_volunteer_team.rb +++ b/db/migrate/20151021183039_create_join_table_volunteer_volunteer_team.rb @@ -1,8 +1,8 @@ class CreateJoinTableVolunteerVolunteerTeam < ActiveRecord::Migration[4.2] def change create_join_table :volunteers, :volunteer_teams do |t| - 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_id, :volunteer_team_id], name: "volunteer_id_volunteer_team_id" + t.index [:volunteer_team_id, :volunteer_id], name: "volunteer_team_id_volunteer_id" end end end diff --git a/db/migrate/20161011005420_add_descriptions_for_all_events.rb b/db/migrate/20161011005420_add_descriptions_for_all_events.rb index 50d1723..d5f02ba 100644 --- a/db/migrate/20161011005420_add_descriptions_for_all_events.rb +++ b/db/migrate/20161011005420_add_descriptions_for_all_events.rb @@ -3,7 +3,7 @@ end class AddDescriptionsForAllEvents < ActiveRecord::Migration[4.2] def up - Event.where(description: [nil, '']).update_all(description: 'n/a') + Event.where(description: [nil, ""]).update_all(description: "n/a") end def down diff --git a/db/migrate/20161015023007_add_participants_view.rb b/db/migrate/20161015023007_add_participants_view.rb index 4ab3db5..4623d46 100644 --- a/db/migrate/20161015023007_add_participants_view.rb +++ b/db/migrate/20161015023007_add_participants_view.rb @@ -1,16 +1,16 @@ -PARTICIPANTS_SQL = < :environment do |t, args| silent = Rake.application.options.silent puts "Backing up '#{conf[:database]}' into: #{args.destination}" unless silent if system(cmd) - puts 'Backup completed.' unless silent + puts "Backup completed." unless silent else puts "Backup failed!\nCommand exit status: #{$?}\nCommand was: #{cmd}" end diff --git a/lib/tasks/bootstrap.rake b/lib/tasks/bootstrap.rake index 94ae034..7754978 100644 --- a/lib/tasks/bootstrap.rake +++ b/lib/tasks/bootstrap.rake @@ -1,34 +1,34 @@ -require 'fileutils' -require 'yaml' -require 'securerandom' +require "fileutils" +require "yaml" +require "securerandom" namespace :bootstrap do - desc 'Copy over initial db config' + desc "Copy over initial db config" task :db_config do - example_config_file = File.join(Rails.root, 'config', 'database.yml.example') - new_config_file = File.join(Rails.root, 'config', 'database.yml') + example_config_file = File.join(Rails.root, "config", "database.yml.example") + new_config_file = File.join(Rails.root, "config", "database.yml") FileUtils.cp example_config_file, new_config_file end - desc 'Generate new secret tokens' + desc "Generate new secret tokens" 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 = { - 'development' => {'secret_key_base' => SecureRandom.hex(64)}, - 'test' => {'secret_key_base' => SecureRandom.hex(64)}, - 'production' => {'secret_key_base' => '<%= ENV["SECRET_KEY_BASE"] %>'} + "development" => {"secret_key_base" => SecureRandom.hex(64)}, + "test" => {"secret_key_base" => SecureRandom.hex(64)}, + "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 end end end -desc 'Perform initial setup of the application' -task bootstrap: ['bootstrap:secret_tokens', - 'bootstrap:db_config', - 'db:create', - 'db:migrate', - 'db:test:prepare'] +desc "Perform initial setup of the application" +task bootstrap: ["bootstrap:secret_tokens", + "bootstrap:db_config", + "db:create", + "db:migrate", + "db:test:prepare",] diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index 52f1be3..c244c2e 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -3,11 +3,11 @@ FactoryBot.define do factory :conference do sequence(:title) { |n| "Conference-#{n}" } - email { 'foo@example.com' } - description { 'MyText' } - start_date { '2014-07-29 21:29:13' } - end_date { '2014-07-31 21:29:13' } - planned_cfp_end_date { '2014-07-28' } + email { "foo@example.com" } + description { "MyText" } + start_date { "2014-07-29 21:29:13" } + end_date { "2014-07-31 21:29:13" } + planned_cfp_end_date { "2014-07-28" } factory :past_conference do start_date { Date.today - 10.days } diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index b3f3ba2..223d22e 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :event_type do name { |n| "Track #{n}" } - description { 'MyText' } + description { "MyText" } conference - minimum_length { '45' } - maximum_length { '60' } + minimum_length { "45" } + maximum_length { "60" } end end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 58eacf6..3afc64d 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :event do title { |n| "Event #{n}" } length { 60 } - abstract { 'foo' } - description { 'foo' } + abstract { "foo" } + description { "foo" } conference language { :bg } after(:build) do |event, evaluator| diff --git a/spec/factories/personal_profile.rb b/spec/factories/personal_profile.rb index 8084392..565dfe7 100644 --- a/spec/factories/personal_profile.rb +++ b/spec/factories/personal_profile.rb @@ -1,14 +1,14 @@ FactoryBot.define do factory :personal_profile do - first_name { 'Foo' } - last_name { 'Bar' } - organisation { 'foo inc.' } - public_email { 'foo@example.com' } - picture { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'picture.jpg')) } - mobile_phone { '+359883444555' } - biography { 'Just a bio' } - github { 'foobar' } - twitter { 'foobar' } + first_name { "Foo" } + last_name { "Bar" } + organisation { "foo inc." } + public_email { "foo@example.com" } + picture { Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "picture.jpg")) } + mobile_phone { "+359883444555" } + biography { "Just a bio" } + github { "foobar" } + twitter { "foobar" } user conference end diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index f91cf4f..87e5372 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -3,8 +3,8 @@ FactoryBot.define do factory :track do name { |n| "Track#{n}" } - color { '#000000' } - description { 'Some description' } + color { "#000000" } + description { "Some description" } conference end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 32299b4..218f1ee 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -4,8 +4,8 @@ FactoryBot.define do sequence(:email) { |n| "user-#{n}@example.org" } factory :user do - password { 'password' } - password_confirmation { 'password' } + password { "password" } + password_confirmation { "password" } confirmed_at { Time.now - 15.minutes } email diff --git a/spec/features/call_for_papers_spec.rb b/spec/features/call_for_papers_spec.rb index 8dc9709..fb35b0e 100644 --- a/spec/features/call_for_papers_spec.rb +++ b/spec/features/call_for_papers_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature 'Call for papers' do +feature "Call for papers" do before do Rails.application.load_seed end @@ -11,21 +11,21 @@ feature 'Call for papers' do sign_out 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) register_a_new_user(false) 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) 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"') @@ -41,7 +41,7 @@ feature 'Call for papers' do sign_out 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) register_a_new_user(false) @@ -57,17 +57,17 @@ feature 'Call for papers' do sign_out 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) submit_an_event_proposition(false) 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"') @@ -76,7 +76,6 @@ feature 'Call for papers' do verify_the_event_is_submitted end - scenario "A returning user resets their password and submits an event proposition" do time_travel_to(2.years.ago) do sign_in_as_admin @@ -84,7 +83,7 @@ feature 'Call for papers' do sign_out 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) register_a_new_user(false) @@ -100,25 +99,25 @@ feature 'Call for papers' do sign_out 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') - fill_in User.human_attribute_name(:email), with: 'bar@example.com' + click_on I18n.t("lostpass") + fill_in User.human_attribute_name(:email), with: "bar@example.com" 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] - 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), with: "foobarbaz" + fill_in User.human_attribute_name(:password_confirmation), with: "foobarbaz" click_on I18n.t(:change_pass) submit_an_event_proposition(false) 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"') diff --git a/spec/features/landing_page_spec.rb b/spec/features/landing_page_spec.rb index 195cb33..4255680 100644 --- a/spec/features/landing_page_spec.rb +++ b/spec/features/landing_page_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature 'Landing page' do +feature "Landing page" do before do Rails.application.load_seed sign_in_as_admin @@ -8,9 +8,8 @@ feature 'Landing page' do sign_out end - it 'displays information about the conference' do + it "displays information about the conference" do visit root_path expect(page).to have_content I18n.t(:home_title, conference: "FooConf #{1.year.from_now.year}") end end - diff --git a/spec/features/management_interface_spec.rb b/spec/features/management_interface_spec.rb index 94ae7c7..533db9b 100644 --- a/spec/features/management_interface_spec.rb +++ b/spec/features/management_interface_spec.rb @@ -1,11 +1,11 @@ require "rails_helper" -feature 'Conference management' do +feature "Conference management" do before do Rails.application.load_seed end - scenario 'Creating a new conference' do + scenario "Creating a new conference" do sign_in_as_admin visit management_root_path expect(page).to_not have_content "FooConf" @@ -14,104 +14,104 @@ feature 'Conference management' do expect(page).to have_content "FooConf" 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 create_new_conference 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 click_on_first_conference_in_management_root - click_on I18n.t('management.conferences.show.cfp_status') - expect(page).to_not have_link I18n.t('views.welcome.submit_event', event_type: '') + click_on I18n.t("management.conferences.show.cfp_status") + expect(page).to_not have_link I18n.t("views.welcome.submit_event", event_type: "") end - scenario 'Editing an existing conference' do + scenario "Editing an existing conference" do sign_in_as_admin create_new_conference - click_on I18n.t('actions.edit.button', model: Conference.model_name.human) - fill_in Conference.human_attribute_name(:title), with: 'FooBarBazConf' - page.find('.btn.btn-primary').click - expect(page).to have_content 'FooBarBazConf' + click_on I18n.t("actions.edit.button", model: Conference.model_name.human) + fill_in Conference.human_attribute_name(:title), with: "FooBarBazConf" + page.find(".btn.btn-primary").click + expect(page).to have_content "FooBarBazConf" end - scenario 'Deleting a newly created conference', js: true do + scenario "Deleting a newly created conference", js: true do sign_in_as_admin - create_new_conference(host_name: '127.0.0.1') - click_on 'Clarion' - expect(page).to have_content 'FooConf' + create_new_conference(host_name: "127.0.0.1") + click_on "Clarion" + expect(page).to have_content "FooConf" click_on_first_conference_in_management_root 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 visit management_root_path - expect(page).to_not have_content 'FooConf' + expect(page).to_not have_content "FooConf" end - scenario 'Reviewing an event' do + scenario "Reviewing an event" do sign_in_as_admin create_new_conference submit_an_event_proposition(true) visit management_root_path click_on_first_conference_in_management_root - click_on I18n.t('activerecord.models.event', count: 2).capitalize - 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') + click_on I18n.t("activerecord.models.event", count: 2).capitalize + 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") end - scenario 'Editing an event' do + scenario "Editing an event" do sign_in_as_admin create_new_conference submit_an_event_proposition(true) visit management_root_path click_on_first_conference_in_management_root - click_on I18n.t('activerecord.models.event', count: 2).capitalize - 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) - 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') - 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' + click_on I18n.t("activerecord.models.event", count: 2).capitalize + 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) + 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") + 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" end - scenario 'Approving an event from its detailed view' do + scenario "Approving an event from its detailed view" do sign_in_as_admin create_new_conference submit_an_event_proposition(true) visit management_root_path 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") - 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.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") end - scenario 'Approving an event from the events index' do + scenario "Approving an event from the events index" do sign_in_as_admin create_new_conference submit_an_event_proposition(true) visit management_root_path 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") click_on I18n.t("status.undecided") click_on I18n.t("status.approved") expect(page).to have_button I18n.t("status.approved") end - scenario 'Creating a profile for a submitter' do + scenario "Creating a profile for a submitter" do sign_in_as_admin create_new_conference submit_an_event_proposition(true) visit management_root_path click_on_first_conference_in_management_root - 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("activerecord.models.personal_profile", count: 2).capitalize + click_on I18n.t("actions.create.title", model: PersonalProfile.model_name.human) fill_in_personal_profile - 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 I18n.t("management.personal_profiles.create.successfully_created") + expect(page).to have_content "Foo Bar" end 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 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) register_a_new_user(false) @@ -137,7 +137,7 @@ feature 'Conference management' do sign_out 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) @@ -146,12 +146,11 @@ feature 'Conference management' do sign_out verify_the_event_is_submitted - click_on I18n.t('activerecord.models.personal_profile', count: 2).capitalize - 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) - expect(page).to have_text(I18n.t('management.personal_profiles.create.successfully_created')) - 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')) + click_on I18n.t("activerecord.models.personal_profile", count: 2).capitalize + 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) + expect(page).to have_text(I18n.t("management.personal_profiles.create.successfully_created")) + 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")) end - end diff --git a/spec/features/volunteership_spec.rb b/spec/features/volunteership_spec.rb index e6c4037..9094c24 100644 --- a/spec/features/volunteership_spec.rb +++ b/spec/features/volunteership_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature 'Volunteering' do +feature "Volunteering" do before do Rails.application.load_seed sign_in_as_admin @@ -8,16 +8,16 @@ feature 'Volunteering' do sign_out 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 - click_on I18n.t('views.volunteers.apply') + click_on I18n.t("views.volunteers.apply") 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 click_on_first_conference_in_management_root - click_on I18n.t('activerecord.models.volunteership', count: 2).capitalize - expect(page).to have_content 'Volunteer Foo' + click_on I18n.t("activerecord.models.volunteership", count: 2).capitalize + expect(page).to have_content "Volunteer Foo" end end diff --git a/spec/models/call_for_participation_spec.rb b/spec/models/call_for_participation_spec.rb index 80594fb..a94dc22 100644 --- a/spec/models/call_for_participation_spec.rb +++ b/spec/models/call_for_participation_spec.rb @@ -1,70 +1,70 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe CallForParticipation, type: :model do let(:conference) { create :conference } 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 cfp = create(:call_for_participation, conference_id: conference.id) expect(CallForParticipation.find(cfp.id).conference).to eq conference end - describe '#open?' do - it 'returns true when the CFP has an opens_at date in the past' do + describe "#open?" do + it "returns true when the CFP has an opens_at date in the past" do cfp.opens_at = 10.minutes.ago expect(cfp.open?).to be true 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 expect(cfp.open?).to be false 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 expect(cfp.open?).to be false end end - describe '#closed?' do - it 'returns true when the CFP has a closes_at date in the past' do + describe "#closed?" do + it "returns true when the CFP has a closes_at date in the past" do cfp.closes_at = 10.minutes.ago expect(cfp.closed?).to be true 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 expect(cfp.closed?).to be false 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 expect(cfp.closed?).to be false end end - describe '#in_progress?' do - it 'returns true when the CFP has been opened and has not been closed' do + describe "#in_progress?" 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(:closed?) { false } expect(cfp.in_progress?).to be true 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.in_progress?).to be false 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(:closed?) { true } @@ -72,32 +72,32 @@ RSpec.describe CallForParticipation, type: :model do end end - describe '#open!' do - it 'changes the status of the CFP to open' do + describe "#open!" do + it "changes the status of the CFP to open" do expect { cfp.open! }.to change { cfp.open? }.from(false).to(true) 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 expect { cfp.open! }.to_not change { cfp.opens_at } 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 expect { cfp.open! }.to change { cfp.closes_at }.to(nil) end - it 'saves the record' do + it "saves the record" do expect { cfp.open! }.to change { cfp.persisted? }.from(false).to(true) end end - describe '#close!' do - it 'changes the status of the CFP to closed' do + describe "#close!" do + it "changes the status of the CFP to closed" do expect { cfp.close! }.to change { cfp.closed? }.from(false).to(true) end - it 'saves the record' do + it "saves the record" do expect { cfp.close! }.to change { cfp.persisted? }.from(false).to(true) end end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 1a9df0a..e2e13e8 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -1,57 +1,57 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe Conference, :type => :model do - describe 'title' do - it 'must not be blank' do - expect(build(:conference, title: '')).to have_error_on :title +RSpec.describe Conference, type: :model do + describe "title" do + it "must not be blank" do + expect(build(:conference, title: "")).to have_error_on :title end - it 'must be unique' do - create :conference, title: 'ExampleConf' - expect(build(:conference, title: 'ExampleConf')).to have_error_on :title + it "must be unique" do + create :conference, title: "ExampleConf" + expect(build(:conference, title: "ExampleConf")).to have_error_on :title end - it 'must be translatable' do + it "must be translatable" do conference = build(:conference) expect(conference).to have_translatable :title end end - describe 'email' do - it 'must be present' do - expect(build(:conference, email: '')).to have_error_on :email + describe "email" do + it "must be present" do + expect(build(:conference, email: "")).to have_error_on :email end - 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_not have_error_on :email - expect(build(:conference, email: 'testexample.com')).to have_error_on :email + 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_not have_error_on :email + expect(build(:conference, email: "testexample.com")).to have_error_on :email end end - describe 'description' do - it 'must be present' do - expect(build(:conference, description: '')).to have_error_on :description + describe "description" do + it "must be present" do + expect(build(:conference, description: "")).to have_error_on :description end - it 'must be translatable' do + it "must be translatable" do expect(build(:conference)).to have_translatable :description 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 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 end - 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 + 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 end - describe 'tracks association' do + describe "tracks association" do let(:conference) { build :conference } let(:track) { build :track } @@ -61,12 +61,12 @@ RSpec.describe Conference, :type => :model do track.save end - it 'links the conference to its tracks' do + it "links the conference to its tracks" do expect(conference.tracks).to include track end end - describe 'halls association' do + describe "halls association" do let(:conference) { build :conference } let(:hall) { build :hall } @@ -76,12 +76,12 @@ RSpec.describe Conference, :type => :model do hall.save end - it 'has many associated halls' do + it "has many associated halls" do expect(conference.halls).to include hall end end - describe 'call for participation association' do + describe "call for participation association" do let(:conference) { build :conference } let(:call_for_participation) { build :call_for_participation } @@ -91,54 +91,54 @@ RSpec.describe Conference, :type => :model do call_for_participation.save 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 end - it 'destroys the associated call for participation when destroyed' do + it "destroys the associated call for participation when destroyed" do conference.destroy expect { CallForParticipation.find(call_for_participation.id) }.to raise_exception ActiveRecord::RecordNotFound 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 expect(conference.call_for_participation).to be_present end end - it 'accepts nested attributes for tracks' do + it "accepts nested attributes for tracks" do track_attributes = build(:track, conference: nil).attributes conference = create :conference expect { conference.update tracks_attributes: [track_attributes]}.to change { conference.tracks.count }.by 1 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 - 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 - it 'allows destruction of tracks by nested attributes' do + it "allows destruction of tracks by nested attributes" do conference = create :conference 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) end - it 'accepts nested attributes for halls' do + it "accepts nested attributes for halls" do hall_attributes = build(:hall, conference: nil).attributes conference = create :conference expect { conference.update halls_attributes: [hall_attributes]}.to change { conference.halls.count }.by 1 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 - 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 - it 'allows destruction of halls by nested attributes' do + it "allows destruction of halls by nested attributes" do conference = create :conference 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) end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 91fe587..4783b3b 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -1,42 +1,42 @@ -require 'rails_helper' +require "rails_helper" describe Event, type: :model do 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 expect(event).to have_error_on :agreement end - it 'is invalid without a title' do - event.title = '' + it "is invalid without a title" do + event.title = "" expect(event).to have_error_on :title end - describe 'length' do - it 'must be present' do - event.length = '' + describe "length" do + it "must be present" do + event.length = "" expect(event).to have_error_on :length end - it 'must be a number' do - event.length = 'foo' + it "must be a number" do + event.length = "foo" expect(event).to have_error_on :length end - it 'must be larger than zero' do - event.length = '-10' + it "must be larger than zero" do + event.length = "-10" expect(event).to have_error_on :length end end - it 'is invalid without an abstract' do - event.abstract = '' + it "is invalid without an abstract" do + event.abstract = "" expect(event).to have_error_on :abstract end - it 'is invalid without a description' do - event.description = '' + it "is invalid without a description" do + event.description = "" expect(event).to have_error_on :description end end diff --git a/spec/models/event_type_spec.rb b/spec/models/event_type_spec.rb index 0673653..7e77915 100644 --- a/spec/models/event_type_spec.rb +++ b/spec/models/event_type_spec.rb @@ -1,32 +1,31 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe EventType, type: :model do - - describe 'description' do - it 'must be present' do + describe "description" do + it "must be present" do expect(build(:event_type, description: nil)).to have_error_on :description end - it 'is translatable' do + it "is translatable" do event_type = build(:event_type) expect(event_type).to have_translatable :description end end - describe 'name' do - it 'must be present' do + describe "name" do + it "must be present" do 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 - it 'must be unique for a event_type' do + it "must be unique for a event_type" do conference = create :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: create(:conference))).to_not have_error_on :name + 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: create(:conference))).to_not have_error_on :name end - it 'is translatable' do + it "is translatable" do event_type = build(:event_type) expect(event_type).to have_translatable :name end diff --git a/spec/models/hall_spec.rb b/spec/models/hall_spec.rb index e1db9a8..09dd352 100644 --- a/spec/models/hall_spec.rb +++ b/spec/models/hall_spec.rb @@ -1,22 +1,22 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe Hall, :type => :model do - it 'is invalid without a name' do - expect(build(:hall, name: '')).to have_error_on :name +RSpec.describe Hall, type: :model do + it "is invalid without a name" do + expect(build(:hall, name: "")).to have_error_on :name end - it 'belongs to a conference' do + it "belongs to a conference" do conference = create :conference expect(build(:hall, conference_id: conference.id).conference).to eq conference end - it 'has many slots' do + it "has many slots" do hall = create :hall slot = create :slot, hall: hall expect(hall.slots).to include slot end - it 'destroys all associated slots when destroyed' do + it "destroys all associated slots when destroyed" do hall = create :hall create :slot, hall: hall expect { hall.destroy }.to change { Slot.count }.by(-1) diff --git a/spec/models/proposition_spec.rb b/spec/models/proposition_spec.rb index 80e5731..2959554 100644 --- a/spec/models/proposition_spec.rb +++ b/spec/models/proposition_spec.rb @@ -1,15 +1,15 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Proposition, type: :model do - it 'belongs to a proposer' do + it "belongs to a proposer" do user = create :user expect(create(:proposition, proposer: user).proposer).to eq user end - it 'belongs to a proposable' do + it "belongs to a proposable" do event = create :event expect(create(:proposition, proposable: event).proposable).to eq event end - it 'is invalid without an existing proposable' + it "is invalid without an existing proposable" end diff --git a/spec/models/slot_spec.rb b/spec/models/slot_spec.rb index 5e4b31e..b62e580 100644 --- a/spec/models/slot_spec.rb +++ b/spec/models/slot_spec.rb @@ -1,12 +1,12 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe Slot, :type => :model do - it 'belongs to a hall' do +RSpec.describe Slot, type: :model do + it "belongs to a hall" do hall = create :hall expect(build(:slot, hall_id: hall.id).hall).to eq hall end - it 'belongs to an event' do + it "belongs to an event" do event = create :event expect(build(:slot, event_id: event.id).event).to eq event end diff --git a/spec/models/track_spec.rb b/spec/models/track_spec.rb index 74d8d02..9eedfa0 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -1,23 +1,23 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe Track, :type => :model do - it 'is invalid without a name' do - expect(build(:track, name: '')).to have_error_on :name +RSpec.describe Track, type: :model do + it "is invalid without a name" do + expect(build(:track, name: "")).to have_error_on :name end - describe 'color' do - it 'must be present' do - expect(build(:track, color: '')).to have_error_on :color + describe "color" do + it "must be present" do + expect(build(:track, color: "")).to have_error_on :color end - it 'must be a hex RGB triplet' do - 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 + it "must be a hex RGB triplet" do + 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 end end - it 'belongs to a conference' do + it "belongs to a conference" do conference = create :conference expect(build(:track, conference_id: conference.id).conference).to eq conference end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 155b44a..2cc7571 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" 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 end end diff --git a/spec/models/volunteership_spec.rb b/spec/models/volunteership_spec.rb index e8bb454..6238804 100644 --- a/spec/models/volunteership_spec.rb +++ b/spec/models/volunteership_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Volunteership, type: :model do pending "add some examples to (or delete) #{__FILE__}" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c258ae4..0399649 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,10 +2,10 @@ # SimpleCov.start 'rails' # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require 'spec_helper' +ENV["RAILS_ENV"] ||= "test" +require "spec_helper" require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' +require "rspec/rails" # Requires supporting ruby files with custom matchers and macros, etc, in # 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 # examples within a transaction, remove the following line or assign false # instead of true. - #config.use_transactional_fixtures = true + # config.use_transactional_fixtures = true # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 85abb10..aeecf49 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,7 +30,7 @@ RSpec.configure do |config| # Use the documentation formatter for detailed output, # unless a formatter has already been configured # (e.g. via a command-line flag). - config.default_formatter = 'doc' + config.default_formatter = "doc" end # Print the 10 slowest examples and example groups at the diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 89af46b..8aefc4a 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,7 +1,7 @@ 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 # RSpec.configure do |config| diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index e9c060c..da6571b 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -27,7 +27,7 @@ RSpec.configure do |config| # with the specs, so continue to use transaction strategy for speed. 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 # under test that does *not* share a database connection with the # specs, so use truncation strategy. diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 2559970..b3febab 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,134 +1,132 @@ module FeatureHelpers def sign_in_as_admin visit management_root_path - within 'section.content' do - fill_in User.human_attribute_name(:email), with: 'foo@example.com' - fill_in User.human_attribute_name(:password), with: '123qweASD' + within "section.content" do + fill_in User.human_attribute_name(:email), with: "foo@example.com" + fill_in User.human_attribute_name(:password), with: "123qweASD" click_on I18n.t(:login) end end def create_new_conference(title = "FooConf #{1.year.from_now.year}", - host_name: 'www.example.com', - planned_cfp_end_date: 1.year.from_now, - start_date: 1.year.from_now + 1.day, - end_date: 1.year.from_now + 2.days) - click_on I18n.t('actions.create.button', model: Conference.model_name.human) + host_name: "www.example.com", + planned_cfp_end_date: 1.year.from_now, + start_date: 1.year.from_now + 1.day, + end_date: 1.year.from_now + 2.days) + click_on I18n.t("actions.create.button", model: Conference.model_name.human) fill_in Conference.human_attribute_name(:title), with: title - fill_in Conference.human_attribute_name(:email), with: 'foo@example.com' + fill_in Conference.human_attribute_name(:email), with: "foo@example.com" fill_in Conference.human_attribute_name(:host_name), with: host_name - select planned_cfp_end_date.year.to_s, from: 'conference[planned_cfp_end_date(1i)]' - select I18n.t('date.month_names')[planned_cfp_end_date.month], from: 'conference[planned_cfp_end_date(2i)]' - select planned_cfp_end_date.day.to_s, from: 'conference[planned_cfp_end_date(3i)]' + select planned_cfp_end_date.year.to_s, from: "conference[planned_cfp_end_date(1i)]" + select I18n.t("date.month_names")[planned_cfp_end_date.month], from: "conference[planned_cfp_end_date(2i)]" + select planned_cfp_end_date.day.to_s, from: "conference[planned_cfp_end_date(3i)]" - select start_date.year.to_s, from: 'conference[start_date(1i)]' - select I18n.t('date.month_names')[start_date.month], from: 'conference[start_date(2i)]' - select start_date.day.to_s, from: 'conference[start_date(3i)]' + select start_date.year.to_s, from: "conference[start_date(1i)]" + select I18n.t("date.month_names")[start_date.month], from: "conference[start_date(2i)]" + select start_date.day.to_s, from: "conference[start_date(3i)]" - select end_date.year.to_s, from: 'conference[end_date(1i)]' - select I18n.t('date.month_names')[end_date.month], from: 'conference[end_date(2i)]' - select end_date.day.to_s, from: 'conference[end_date(3i)]' + select end_date.year.to_s, from: "conference[end_date(1i)]" + select I18n.t("date.month_names")[end_date.month], from: "conference[end_date(2i)]" + select end_date.day.to_s, from: "conference[end_date(3i)]" - within '.form-group.conference_description' do - fill_in Conference.human_attribute_name(:description), with: 'Lorem' + within ".form-group.conference_description" do + fill_in Conference.human_attribute_name(:description), with: "Lorem" end - within '#event_types' do - fill_in EventType.human_attribute_name(:description), with: 'Lorem' - fill_in EventType.human_attribute_name(:minimum_length), with: '45' - fill_in EventType.human_attribute_name(:maximum_length), with: '45' - + within "#event_types" do + fill_in EventType.human_attribute_name(:description), with: "Lorem" + fill_in EventType.human_attribute_name(:minimum_length), with: "45" + fill_in EventType.human_attribute_name(:maximum_length), with: "45" end - within '#tracks' do - fill_in Track.human_attribute_name(:description), with: 'Lorem' + within "#tracks" do + fill_in Track.human_attribute_name(:description), with: "Lorem" end - within '#volunteer_teams' do - fill_in VolunteerTeam.human_attribute_name(:description), with: 'Lorem' + within "#volunteer_teams" do + fill_in VolunteerTeam.human_attribute_name(:description), with: "Lorem" end - page.find('.btn.btn-primary').click + page.find(".btn.btn-primary").click - click_on I18n.t('management.conferences.show.cfp_status') + click_on I18n.t("management.conferences.show.cfp_status") end def sign_out - click_on I18n.t('sessions.sign_out') + click_on I18n.t("sessions.sign_out") end def register_a_new_user(visit_registration_path = true) if visit_registration_path - click_on I18n.t('sessions.sign_in') + click_on I18n.t("sessions.sign_in") end - fill_in User.human_attribute_name(:email), with: 'bar@example.com' - fill_in User.human_attribute_name(:password), with: '123qweASD' - fill_in User.human_attribute_name(:password_confirmation), with: '123qweASD' + fill_in User.human_attribute_name(:email), with: "bar@example.com" + fill_in User.human_attribute_name(:password), with: "123qweASD" + fill_in User.human_attribute_name(:password_confirmation), with: "123qweASD" - within '.form-actions' do - page.find('.btn').click + within ".form-actions" do + page.find(".btn").click end visit(user_confirmation_path + "?confirmation_token=" + User.order(created_at: :desc).first.confirmation_token) end def sign_in_as_an_existing_user(visit_sign_in_path = true) if visit_sign_in_path - click_on I18n.t('sessions.sign_in') + click_on I18n.t("sessions.sign_in") end - within 'section.content' do - fill_in User.human_attribute_name(:email), with: 'bar@example.com' - fill_in User.human_attribute_name(:password), with: '123qweASD' + within "section.content" do + fill_in User.human_attribute_name(:email), with: "bar@example.com" + fill_in User.human_attribute_name(:password), with: "123qweASD" click_on I18n.t(:login) end end - def submit_an_event_proposition(visit_event_submission_path = true) if visit_event_submission_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) end - fill_in Event.human_attribute_name(:title), with: 'This is just a sample title of an event' + fill_in Event.human_attribute_name(:title), with: "This is just a sample title of an event" select Conference.first.tracks.first.name, from: Event.human_attribute_name(:track) - fill_in Event.human_attribute_name(:length), with: '45' - fill_in Event.human_attribute_name(:abstract), with: 'Lorem' - fill_in Event.human_attribute_name(:description), with: 'Ipsum' + fill_in Event.human_attribute_name(:length), with: "45" + fill_in Event.human_attribute_name(:abstract), with: "Lorem" + fill_in Event.human_attribute_name(:description), with: "Ipsum" check Event.human_attribute_name(:agreement) - click_on I18n.t('helpers.submit.event.create') + click_on I18n.t("helpers.submit.event.create") end def fill_in_personal_profile - attach_file PersonalProfile.human_attribute_name(:picture), Rails.root.join('spec', 'support', 'picture.jpg') - fill_in PersonalProfile.human_attribute_name(:first_name), with: 'Foo' - fill_in PersonalProfile.human_attribute_name(:last_name), with: 'Bar' - fill_in PersonalProfile.human_attribute_name(:mobile_phone), with: '+359666666' - fill_in PersonalProfile.human_attribute_name(:biography), with: 'Lorem' + attach_file PersonalProfile.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg") + fill_in PersonalProfile.human_attribute_name(:first_name), with: "Foo" + fill_in PersonalProfile.human_attribute_name(:last_name), with: "Bar" + fill_in PersonalProfile.human_attribute_name(:mobile_phone), with: "+359666666" + fill_in PersonalProfile.human_attribute_name(:biography), with: "Lorem" - click_on I18n.t('helpers.submit.create', model: PersonalProfile.model_name.human) + click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human) end def fill_in_volunteer_profile - attach_file Volunteer.human_attribute_name(:picture), Rails.root.join('spec', 'support', 'picture.jpg') - fill_in Volunteer.human_attribute_name(:name), with: 'Volunteer Foo' - fill_in Volunteer.human_attribute_name(:email), with: 'foo@example.com' - fill_in Volunteer.human_attribute_name(:phone), with: '+359666666' + attach_file Volunteer.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg") + fill_in Volunteer.human_attribute_name(:name), with: "Volunteer Foo" + fill_in Volunteer.human_attribute_name(:email), with: "foo@example.com" + fill_in Volunteer.human_attribute_name(:phone), with: "+359666666" check VolunteerTeam.first.name - click_on I18n.t('helpers.submit.volunteer.create') + click_on I18n.t("helpers.submit.volunteer.create") end def verify_the_event_is_submitted sign_in_as_admin click_on_first_conference_in_management_root click_on Event.model_name.human(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" end def click_on_first_conference_in_management_root - click_on I18n.t('actions.view.button', model: Conference.model_name.human), match: :first + click_on I18n.t("actions.view.button", model: Conference.model_name.human), match: :first end end diff --git a/spec/support/matchers/has_translatable.rb b/spec/support/matchers/has_translatable.rb index cef584d..09721fb 100644 --- a/spec/support/matchers/has_translatable.rb +++ b/spec/support/matchers/has_translatable.rb @@ -1,14 +1,14 @@ RSpec::Matchers.define :have_translatable do |expected| match do |actual| I18n.locale = :bg - actual.send "#{expected.to_s}=", 'Test Bulgarian' + actual.send "#{expected}=", "Test Bulgarian" I18n.locale = :en - actual.send "#{expected.to_s}=", 'Test English' + actual.send "#{expected}=", "Test English" - expect(actual.send expected).to eq 'Test English' + expect(actual.send(expected)).to eq "Test English" I18n.locale = :bg - expect(actual.send expected).to eq 'Test Bulgarian' + expect(actual.send(expected)).to eq "Test Bulgarian" end end