diff --git a/Gemfile b/Gemfile index 0806088d..79bbdb3f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,10 @@ if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') end # as web framework -gem 'rails', '~> 4.2.8' +gem 'rails', '~> 5.0.5' + +# Use Puma as the app server +gem 'puma', '~> 3.0' # enables serving assets in production and setting your logger to standard out # both of which are required to run an application on a twelve-factor provider @@ -31,7 +34,7 @@ gem 'carrierwave-bombshelter' gem 'mini_magick' # for internationalizing -gem 'rails-i18n', '~> 4.0.0' +gem 'rails-i18n', '~> 5.0.0' # as authentification framework gem 'devise' @@ -48,7 +51,7 @@ gem 'omniauth-openid' gem 'recaptcha', require: 'recaptcha/rails' # as authorization framework -gem 'cancancan' +gem 'cancancan', '~> 2.0' # for roles gem 'rolify' @@ -76,7 +79,7 @@ gem 'uglifier', '>= 1.3.0' gem 'autoprefixer-rails' gem 'bootstrap-sass', '~> 3.3.4.1' gem 'cocoon' -gem 'formtastic', '~> 3.1.1' +gem 'formtastic', '~> 3.1.5' gem 'formtastic-bootstrap' # as the JavaScript library @@ -156,7 +159,6 @@ gem 'redcarpet' gem 'rdoc-generator-fivefish' # for visitor tracking -gem 'activeuuid' gem 'ahoy_matey' gem 'piwik_analytics', '~> 1.0.1' @@ -253,6 +255,8 @@ group :test do gem 'stripe-ruby-mock' # For validating JSON schemas gem 'json-schema' + # For using 'assigns' in tests + gem 'rails-controller-testing' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index eb9eed9e..1023f255 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,62 +12,65 @@ GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actionmailer (4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) + actioncable (5.0.5) + actionpack (= 5.0.5) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.5) + actionpack (= 5.0.5) + actionview (= 5.0.5) + activejob (= 5.0.5) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.9) - actionview (= 4.2.9) - activesupport (= 4.2.9) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.5) + actionview (= 5.0.5) + activesupport (= 5.0.5) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.9) - activesupport (= 4.2.9) + actionview (5.0.5) + activesupport (= 5.0.5) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.9.4) activemodel (>= 3.2) - activejob (4.2.9) - activesupport (= 4.2.9) - globalid (>= 0.3.0) - activemodel (4.2.9) - activesupport (= 4.2.9) - builder (~> 3.1) - activerecord (4.2.9) - activemodel (= 4.2.9) - activesupport (= 4.2.9) - arel (~> 6.0) - activesupport (4.2.9) + activejob (5.0.5) + activesupport (= 5.0.5) + globalid (>= 0.3.6) + activemodel (5.0.5) + activesupport (= 5.0.5) + activerecord (5.0.5) + activemodel (= 5.0.5) + activesupport (= 5.0.5) + arel (~> 7.0) + activesupport (5.0.5) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - activeuuid (0.6.1) - activerecord (>= 3.1) - uuidtools acts_as_commentable_with_threading (1.2.0) activerecord (>= 3.0) activesupport (>= 3.0) awesome_nested_set (>= 2.0) - acts_as_list (0.4.0) + acts_as_list (0.9.7) activerecord (>= 3.0) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) - ahoy_matey (1.0.0) + ahoy_matey (1.6.0) addressable - browser (>= 0.4.0) + browser (~> 2.0) geocoder - referer-parser + rack-attack (< 6) + railties + referer-parser (>= 0.3.0) request_store + safely_block (>= 0.1.1) user_agent_parser uuidtools - arel (6.0.4) + arel (7.1.4) ast (2.3.0) autoprefixer-rails (7.1.1) execjs @@ -86,10 +89,10 @@ GEM bootstrap-switch-rails (3.0.2) bootstrap3-datetimepicker-rails (3.0.3) momentjs-rails (>= 2.8.1) - browser (0.6.0) + browser (2.5.1) builder (3.2.3) byebug (9.0.6) - cancancan (1.13.1) + cancancan (2.0.0) capybara (2.6.2) addressable mime-types (>= 1.16) @@ -144,7 +147,7 @@ GEM daemons (1.1.9) dante (0.2.0) database_cleaner (1.3.0) - debug_inspector (0.0.2) + debug_inspector (0.0.3) delayed_job (4.1.3) activesupport (>= 3.0, < 5.2) delayed_job_active_record (4.1.2) @@ -166,6 +169,7 @@ GEM dotenv-rails (2.2.1) dotenv (= 2.2.1) railties (>= 3.2, < 5.2) + errbase (0.0.3) erubis (2.7.0) execjs (2.6.0) factory_girl (4.5.0) @@ -184,11 +188,11 @@ GEM font-awesome-rails (4.7.0.2) railties (>= 3.2, < 5.2) formatador (0.2.5) - formtastic (3.1.3) + formtastic (3.1.5) actionpack (>= 3.2.13) formtastic-bootstrap (3.1.1) formtastic (>= 3.0) - geocoder (1.2.2) + geocoder (1.4.4) globalid (0.4.0) activesupport (>= 4.2.0) gravtastic (3.2.6) @@ -291,6 +295,7 @@ GEM mysql2 (0.4.9) nenv (0.3.0) netrc (0.11.0) + nio4r (2.1.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) notiffany (0.1.1) @@ -354,23 +359,27 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) public_suffix (2.0.5) - rack (1.6.8) + puma (3.10.0) + rack (2.0.3) + rack-attack (5.0.1) + rack rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.9) - actionmailer (= 4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) - activemodel (= 4.2.9) - activerecord (= 4.2.9) - activesupport (= 4.2.9) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.9) - sprockets-rails + rails (5.0.5) + actioncable (= 5.0.5) + actionmailer (= 5.0.5) + actionpack (= 5.0.5) + actionview (= 5.0.5) + activejob (= 5.0.5) + activemodel (= 5.0.5) + activerecord (= 5.0.5) + activesupport (= 5.0.5) + bundler (>= 1.3.0) + railties (= 5.0.5) + sprockets-rails (>= 2.0.0) rails-assets-bootstrap (3.3.6) rails-assets-jquery (>= 1.9.1, < 3) rails-assets-bootstrap-markdown (2.10.0) @@ -388,25 +397,27 @@ GEM rails-assets-to-markdown (1.3.0) rails-assets-trianglify (0.4.0) rails-assets-waypoints (4.0.0) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.8) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) + rails-controller-testing (1.0.2) + actionpack (~> 5.x, >= 5.0.1) + actionview (~> 5.x, >= 5.0.1) + activesupport (~> 5.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - rails-i18n (4.0.8) + rails-i18n (5.0.4) i18n (~> 0.7) - railties (~> 4.0) + railties (~> 5.0) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.4) rails_stdout_logging (0.0.3) - railties (4.2.9) - actionpack (= 4.2.9) - activesupport (= 4.2.9) + railties (5.0.5) + actionpack (= 5.0.5) + activesupport (= 5.0.5) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) @@ -424,7 +435,7 @@ GEM recaptcha (4.6.2) json redcarpet (3.2.3) - referer-parser (0.2.1) + referer-parser (0.3.0) request_store (1.1.0) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) @@ -474,6 +485,8 @@ GEM ruby_dep (1.5.0) rubyzip (1.2.1) safe_yaml (1.0.4) + safely_block (0.2.0) + errbase sass (3.2.19) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -500,10 +513,10 @@ GEM sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sqlite3 (1.3.9) stripe (1.43.0) rest-client (~> 1.4) @@ -534,11 +547,11 @@ GEM unicode_utils (1.4.0) unobtrusive_flash (3.1.0) railties - user_agent_parser (2.1.5) + user_agent_parser (2.4.0) uuidtools (2.1.5) warden (1.2.4) rack (>= 1.0) - web-console (2.2.1) + web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) @@ -562,7 +575,6 @@ PLATFORMS DEPENDENCIES active_model_serializers - activeuuid acts_as_commentable_with_threading acts_as_list ahoy_matey @@ -574,7 +586,7 @@ DEPENDENCIES bootstrap-switch-rails (~> 3.0.0) bootstrap3-datetimepicker-rails (~> 3.0.2) byebug - cancancan + cancancan (~> 2.0) capybara carrierwave carrierwave-bombshelter @@ -594,7 +606,7 @@ DEPENDENCIES faker feature font-awesome-rails - formtastic (~> 3.1.1) + formtastic (~> 3.1.5) formtastic-bootstrap gravtastic guard-rspec @@ -625,7 +637,8 @@ DEPENDENCIES poltergeist prawn-qrcode (~> 0.2.2.1) prawn_rails - rails (~> 4.2.8) + puma (~> 3.0) + rails (~> 5.0.5) rails-assets-bootstrap-markdown! rails-assets-date.format! rails-assets-holderjs! @@ -637,7 +650,8 @@ DEPENDENCIES rails-assets-to-markdown! rails-assets-trianglify! rails-assets-waypoints! - rails-i18n (~> 4.0.0) + rails-controller-testing + rails-i18n (~> 5.0.0) rails_12factor rdoc-generator-fivefish recaptcha diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 631dd4d8..ab9719bd 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,6 +1,6 @@ module Admin class BaseController < ApplicationController - before_filter :verify_user_admin + before_action :verify_user_admin private diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 2afb8f6a..475c18c8 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -2,7 +2,7 @@ module Admin class RegistrationsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource :registration, through: :conference - before_filter :set_user, except: [:index] + before_action :set_user, except: [:index] def index authorize! :show, Registration.new(conference_id: @conference.id) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f1a31894..7421a0f0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,10 +1,10 @@ class ApplicationController < ActionController::Base - before_filter :set_paper_trail_whodunnit + before_action :set_paper_trail_whodunnit include ApplicationHelper add_flash_types :error - protect_from_forgery with: :exception - before_filter :get_conferences - before_filter :store_location + protect_from_forgery with: :exception, prepend: true + before_action :get_conferences + before_action :store_location # Ensure every controller authorizes resource or skips authorization (skip_authorization_check) check_authorization unless: :devise_controller? diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index e8809b28..f2751a31 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -1,5 +1,5 @@ class ConferenceRegistrationsController < ApplicationController - before_filter :authenticate_user!, except: [:new, :create] + before_action :authenticate_user!, except: [:new, :create] load_resource :conference, find_by: :short_title authorize_resource :conference_registrations, class: Registration, except: [:new, :create] before_action :set_registration, only: [:edit, :update, :destroy, :show] diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 76d5c74a..d5111835 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -1,5 +1,5 @@ class SubscriptionsController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! load_resource :conference, find_by: :short_title load_and_authorize_resource only: [:create, :destroy], through: :conference diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 3eb8b68d..dbf4755e 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -1,5 +1,5 @@ class TicketPurchasesController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! load_resource :conference, find_by: :short_title authorize_resource :conference_registrations, class: Registration authorize_resource diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 55c73fc0..94893c27 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -1,9 +1,9 @@ class TicketsController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! load_resource :conference, find_by: :short_title load_resource :ticket, through: :conference authorize_resource :conference_registrations, class: Registration - before_filter :check_load_resource, only: :index + before_action :check_load_resource, only: :index def index; end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 00000000..a009ace5 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/jobs/conference_cfp_update_mail_job.rb b/app/jobs/conference_cfp_update_mail_job.rb index f732c068..7138bd59 100644 --- a/app/jobs/conference_cfp_update_mail_job.rb +++ b/app/jobs/conference_cfp_update_mail_job.rb @@ -1,4 +1,4 @@ -class ConferenceCfpUpdateMailJob < ActiveJob::Base +class ConferenceCfpUpdateMailJob < ApplicationJob queue_as :default def perform(conference) diff --git a/app/jobs/conference_date_update_mail_job.rb b/app/jobs/conference_date_update_mail_job.rb index e8eeae12..4218d22f 100644 --- a/app/jobs/conference_date_update_mail_job.rb +++ b/app/jobs/conference_date_update_mail_job.rb @@ -1,4 +1,4 @@ -class ConferenceDateUpdateMailJob < ActiveJob::Base +class ConferenceDateUpdateMailJob < ApplicationJob queue_as :default def perform(conference) diff --git a/app/jobs/conference_registration_date_update_mail_job.rb b/app/jobs/conference_registration_date_update_mail_job.rb index 9015d8af..ed7ee084 100644 --- a/app/jobs/conference_registration_date_update_mail_job.rb +++ b/app/jobs/conference_registration_date_update_mail_job.rb @@ -1,4 +1,4 @@ -class ConferenceRegistrationDateUpdateMailJob < ActiveJob::Base +class ConferenceRegistrationDateUpdateMailJob < ApplicationJob queue_as :default def perform(conference) diff --git a/app/jobs/conference_schedule_update_mail_job.rb b/app/jobs/conference_schedule_update_mail_job.rb index a6c73eca..02d03352 100644 --- a/app/jobs/conference_schedule_update_mail_job.rb +++ b/app/jobs/conference_schedule_update_mail_job.rb @@ -1,4 +1,4 @@ -class ConferenceScheduleUpdateMailJob < ActiveJob::Base +class ConferenceScheduleUpdateMailJob < ApplicationJob queue_as :default def perform(conference) diff --git a/app/jobs/conference_venue_update_mail_job.rb b/app/jobs/conference_venue_update_mail_job.rb index 2aa960d1..30203639 100644 --- a/app/jobs/conference_venue_update_mail_job.rb +++ b/app/jobs/conference_venue_update_mail_job.rb @@ -1,4 +1,4 @@ -class ConferenceVenueUpdateMailJob < ActiveJob::Base +class ConferenceVenueUpdateMailJob < ApplicationJob queue_as :default def perform(conference) diff --git a/app/jobs/event_comment_mail_job.rb b/app/jobs/event_comment_mail_job.rb index 28564a1d..36bc9294 100644 --- a/app/jobs/event_comment_mail_job.rb +++ b/app/jobs/event_comment_mail_job.rb @@ -1,4 +1,4 @@ -class EventCommentMailJob < ActiveJob::Base +class EventCommentMailJob < ApplicationJob queue_as :default def perform(comment) diff --git a/app/models/ahoy/event.rb b/app/models/ahoy/event.rb index a70e7e41..74758c47 100644 --- a/app/models/ahoy/event.rb +++ b/app/models/ahoy/event.rb @@ -1,5 +1,5 @@ module Ahoy - class Event < ActiveRecord::Base + class Event < ApplicationRecord self.table_name = 'ahoy_events' belongs_to :visit diff --git a/app/models/answer.rb b/app/models/answer.rb index 31dee54b..6d1bca3c 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,4 +1,4 @@ -class Answer < ActiveRecord::Base +class Answer < ApplicationRecord has_many :qanswers has_many :questions, through: :qanswers diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 00000000..10a4cba8 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/booth.rb b/app/models/booth.rb index 4e42d839..e64a230a 100644 --- a/app/models/booth.rb +++ b/app/models/booth.rb @@ -1,4 +1,4 @@ -class Booth < ActiveRecord::Base +class Booth < ApplicationRecord include ActiveRecord::Transitions has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/booth_request.rb b/app/models/booth_request.rb index 438b4167..f57c712e 100644 --- a/app/models/booth_request.rb +++ b/app/models/booth_request.rb @@ -1,4 +1,4 @@ -class BoothRequest < ActiveRecord::Base +class BoothRequest < ApplicationRecord belongs_to :booth belongs_to :user diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 28cddbbd..103274a0 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -1,4 +1,4 @@ -class Campaign < ActiveRecord::Base +class Campaign < ApplicationRecord validates :name, :utm_campaign, presence: true has_many :targets, dependent: :nullify diff --git a/app/models/cfp.rb b/app/models/cfp.rb index 17b37809..5105a6bd 100644 --- a/app/models/cfp.rb +++ b/app/models/cfp.rb @@ -1,6 +1,6 @@ # cannot delete program if there are events submitted -class Cfp < ActiveRecord::Base +class Cfp < ApplicationRecord TYPES = %w(events booths tracks).freeze has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/comment.rb b/app/models/comment.rb index 4bb90719..535eea57 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,4 +1,4 @@ -class Comment < ActiveRecord::Base +class Comment < ApplicationRecord acts_as_nested_set scope: %i(commentable_id commentable_type) validates :body, presence: true validates :user, presence: true diff --git a/app/models/commercial.rb b/app/models/commercial.rb index a2245d07..0976fe44 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -1,4 +1,4 @@ -class Commercial < ActiveRecord::Base +class Commercial < ApplicationRecord require 'oembed' belongs_to :commercialable, polymorphic: true diff --git a/app/models/conference.rb b/app/models/conference.rb index c56161f2..b12137d8 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -1,4 +1,4 @@ -class Conference < ActiveRecord::Base +class Conference < ApplicationRecord include RevisionCount require 'uri' serialize :events_per_week, Hash diff --git a/app/models/contact.rb b/app/models/contact.rb index 3f8216df..799c8748 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,4 +1,4 @@ -class Contact < ActiveRecord::Base +class Contact < ApplicationRecord has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id } belongs_to :conference diff --git a/app/models/difficulty_level.rb b/app/models/difficulty_level.rb index b5d971a7..e81ce026 100644 --- a/app/models/difficulty_level.rb +++ b/app/models/difficulty_level.rb @@ -1,4 +1,4 @@ -class DifficultyLevel < ActiveRecord::Base +class DifficultyLevel < ApplicationRecord belongs_to :program has_many :events, dependent: :nullify diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb index 6210cf9d..2c593b96 100644 --- a/app/models/email_settings.rb +++ b/app/models/email_settings.rb @@ -1,4 +1,4 @@ -class EmailSettings < ActiveRecord::Base +class EmailSettings < ApplicationRecord belongs_to :conference has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/event.rb b/app/models/event.rb index 360421f5..34c217f3 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,4 +1,4 @@ -class Event < ActiveRecord::Base +class Event < ApplicationRecord include ActiveRecord::Transitions include RevisionCount has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id } diff --git a/app/models/event_schedule.rb b/app/models/event_schedule.rb index 57edbec0..cb5d1675 100644 --- a/app/models/event_schedule.rb +++ b/app/models/event_schedule.rb @@ -1,4 +1,4 @@ -class EventSchedule < ActiveRecord::Base +class EventSchedule < ApplicationRecord belongs_to :schedule belongs_to :event belongs_to :room diff --git a/app/models/event_type.rb b/app/models/event_type.rb index 47da514f..8e4b4497 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,4 +1,4 @@ -class EventType < ActiveRecord::Base +class EventType < ApplicationRecord belongs_to :program has_many :events, dependent: :restrict_with_error diff --git a/app/models/event_user.rb b/app/models/event_user.rb index 70d9ca91..6feb9521 100644 --- a/app/models/event_user.rb +++ b/app/models/event_user.rb @@ -1,4 +1,4 @@ -class EventUser < ActiveRecord::Base +class EventUser < ApplicationRecord # TODO: Do we need these roles? ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]] diff --git a/app/models/events_registration.rb b/app/models/events_registration.rb index fcebd69f..6539064e 100644 --- a/app/models/events_registration.rb +++ b/app/models/events_registration.rb @@ -1,4 +1,4 @@ -class EventsRegistration < ActiveRecord::Base +class EventsRegistration < ApplicationRecord belongs_to :registration belongs_to :event diff --git a/app/models/lodging.rb b/app/models/lodging.rb index 21e4a8b0..50feaf41 100644 --- a/app/models/lodging.rb +++ b/app/models/lodging.rb @@ -1,4 +1,4 @@ -class Lodging < ActiveRecord::Base +class Lodging < ApplicationRecord belongs_to :conference has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/openid.rb b/app/models/openid.rb index 2fc1c245..2b954f8b 100644 --- a/app/models/openid.rb +++ b/app/models/openid.rb @@ -1,4 +1,4 @@ -class Openid < ActiveRecord::Base +class Openid < ApplicationRecord belongs_to :user validates :provider, :uid, presence: true diff --git a/app/models/organization.rb b/app/models/organization.rb index 0354df5b..21d0989b 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,4 +1,4 @@ -class Organization < ActiveRecord::Base +class Organization < ApplicationRecord resourcify :roles, dependent: :delete_all has_paper_trail diff --git a/app/models/payment.rb b/app/models/payment.rb index e9386a35..3938dcb6 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -1,4 +1,4 @@ -class Payment < ActiveRecord::Base +class Payment < ApplicationRecord has_many :ticket_purchases belongs_to :user belongs_to :conference diff --git a/app/models/physical_ticket.rb b/app/models/physical_ticket.rb index 689d118a..e98646b0 100644 --- a/app/models/physical_ticket.rb +++ b/app/models/physical_ticket.rb @@ -1,4 +1,4 @@ -class PhysicalTicket < ActiveRecord::Base +class PhysicalTicket < ApplicationRecord belongs_to :ticket_purchase has_one :ticket, through: :ticket_purchase has_one :conference, through: :ticket_purchase diff --git a/app/models/program.rb b/app/models/program.rb index addda157..4f0298f4 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -1,6 +1,6 @@ # cannot delete program if there are events submitted -class Program < ActiveRecord::Base +class Program < ApplicationRecord has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id } belongs_to :conference diff --git a/app/models/qanswer.rb b/app/models/qanswer.rb index 730d98e7..2e581131 100644 --- a/app/models/qanswer.rb +++ b/app/models/qanswer.rb @@ -1,4 +1,4 @@ -class Qanswer < ActiveRecord::Base +class Qanswer < ApplicationRecord belongs_to :question belongs_to :answer, dependent: :delete diff --git a/app/models/question.rb b/app/models/question.rb index 4d8a33d0..0c7456a9 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,4 +1,4 @@ -class Question < ActiveRecord::Base +class Question < ApplicationRecord belongs_to :question_type has_and_belongs_to_many :conferences diff --git a/app/models/question_type.rb b/app/models/question_type.rb index df063568..84fd1a80 100644 --- a/app/models/question_type.rb +++ b/app/models/question_type.rb @@ -1,3 +1,3 @@ -class QuestionType < ActiveRecord::Base +class QuestionType < ApplicationRecord has_many :questions end diff --git a/app/models/registration.rb b/app/models/registration.rb index 7003dfd7..1198324e 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -1,4 +1,4 @@ -class Registration < ActiveRecord::Base +class Registration < ApplicationRecord belongs_to :user belongs_to :conference diff --git a/app/models/registration_period.rb b/app/models/registration_period.rb index fb9e6225..9aa82444 100644 --- a/app/models/registration_period.rb +++ b/app/models/registration_period.rb @@ -1,4 +1,4 @@ -class RegistrationPeriod < ActiveRecord::Base +class RegistrationPeriod < ApplicationRecord belongs_to :conference has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/resource.rb b/app/models/resource.rb index ce6e7b94..77363cfb 100644 --- a/app/models/resource.rb +++ b/app/models/resource.rb @@ -1,4 +1,4 @@ -class Resource < ActiveRecord::Base +class Resource < ApplicationRecord belongs_to :conference validates :name, :used, :quantity, presence: true validates :used, :quantity, numericality: { greater_than_or_equal_to: 0, only_integer: true } diff --git a/app/models/role.rb b/app/models/role.rb index c827d0dd..fcbac932 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,4 +1,4 @@ -class Role < ActiveRecord::Base +class Role < ApplicationRecord belongs_to :resource, polymorphic: true has_many :users_roles has_many :users, through: :users_roles diff --git a/app/models/room.rb b/app/models/room.rb index 8a50551d..718704de 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,4 +1,4 @@ -class Room < ActiveRecord::Base +class Room < ApplicationRecord include RevisionCount belongs_to :venue has_many :event_schedules, dependent: :destroy diff --git a/app/models/schedule.rb b/app/models/schedule.rb index 082d0af0..3bd1f1fa 100644 --- a/app/models/schedule.rb +++ b/app/models/schedule.rb @@ -1,4 +1,4 @@ -class Schedule < ActiveRecord::Base +class Schedule < ApplicationRecord belongs_to :program belongs_to :track has_many :event_schedules, dependent: :destroy diff --git a/app/models/splashpage.rb b/app/models/splashpage.rb index 15447aa9..388831ba 100644 --- a/app/models/splashpage.rb +++ b/app/models/splashpage.rb @@ -1,4 +1,4 @@ -class Splashpage < ActiveRecord::Base +class Splashpage < ApplicationRecord belongs_to :conference has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } diff --git a/app/models/sponsor.rb b/app/models/sponsor.rb index df687f20..d54d95c7 100644 --- a/app/models/sponsor.rb +++ b/app/models/sponsor.rb @@ -1,4 +1,4 @@ -class Sponsor < ActiveRecord::Base +class Sponsor < ApplicationRecord belongs_to :sponsorship_level belongs_to :conference diff --git a/app/models/sponsorship_level.rb b/app/models/sponsorship_level.rb index da411859..f742e41b 100644 --- a/app/models/sponsorship_level.rb +++ b/app/models/sponsorship_level.rb @@ -1,4 +1,4 @@ -class SponsorshipLevel < ActiveRecord::Base +class SponsorshipLevel < ApplicationRecord validates :title, presence: true belongs_to :conference acts_as_list scope: :conference diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 984c46f3..9d78975a 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -1,4 +1,4 @@ -class Subscription < ActiveRecord::Base +class Subscription < ApplicationRecord belongs_to :conference belongs_to :user diff --git a/app/models/target.rb b/app/models/target.rb index 6581c48d..55365a6a 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -1,4 +1,4 @@ -class Target < ActiveRecord::Base +class Target < ApplicationRecord include ActionView::Helpers::TextHelper default_scope { order('due_date ASC') } diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 97a3089b..b49cf1b9 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,4 +1,4 @@ -class Ticket < ActiveRecord::Base +class Ticket < ApplicationRecord belongs_to :conference has_many :ticket_purchases, dependent: :destroy has_many :buyers, -> { distinct }, through: :ticket_purchases, source: :user diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 71b44d18..15de3785 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -1,4 +1,4 @@ -class TicketPurchase < ActiveRecord::Base +class TicketPurchase < ApplicationRecord belongs_to :ticket belongs_to :user belongs_to :conference diff --git a/app/models/ticket_scanning.rb b/app/models/ticket_scanning.rb index 350d4f9b..27536c86 100644 --- a/app/models/ticket_scanning.rb +++ b/app/models/ticket_scanning.rb @@ -1,4 +1,4 @@ -class TicketScanning < ActiveRecord::Base +class TicketScanning < ApplicationRecord belongs_to :physical_ticket before_create :mark_user_present diff --git a/app/models/track.rb b/app/models/track.rb index 02d49f8c..01755c0e 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,4 +1,4 @@ -class Track < ActiveRecord::Base +class Track < ApplicationRecord include ActiveRecord::Transitions include RevisionCount diff --git a/app/models/user.rb b/app/models/user.rb index 231e1c11..4510aece 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ end class UserDisabled < StandardError end -class User < ActiveRecord::Base +class User < ApplicationRecord rolify has_many :physical_tickets, through: :ticket_purchases do def by_conference(conference) diff --git a/app/models/users_role.rb b/app/models/users_role.rb index 3a3afaba..f233e995 100644 --- a/app/models/users_role.rb +++ b/app/models/users_role.rb @@ -1,4 +1,4 @@ -class UsersRole < ActiveRecord::Base +class UsersRole < ApplicationRecord belongs_to :role belongs_to :user diff --git a/app/models/vchoice.rb b/app/models/vchoice.rb index cc09574a..b258c34d 100644 --- a/app/models/vchoice.rb +++ b/app/models/vchoice.rb @@ -1,4 +1,4 @@ -class Vchoice < ActiveRecord::Base +class Vchoice < ApplicationRecord belongs_to :vday belongs_to :vposition diff --git a/app/models/vday.rb b/app/models/vday.rb index 33de4ba7..bd122291 100644 --- a/app/models/vday.rb +++ b/app/models/vday.rb @@ -1,4 +1,4 @@ -class Vday < ActiveRecord::Base +class Vday < ApplicationRecord belongs_to :conference has_many :vchoices diff --git a/app/models/venue.rb b/app/models/venue.rb index 76d7de5e..6a758242 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,4 +1,4 @@ -class Venue < ActiveRecord::Base +class Venue < ApplicationRecord belongs_to :conference has_one :commercial, as: :commercialable, dependent: :destroy has_many :rooms, dependent: :destroy diff --git a/app/models/visit.rb b/app/models/visit.rb index 4ae9bb97..76b1981b 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -1,4 +1,4 @@ -class Visit < ActiveRecord::Base +class Visit < ApplicationRecord has_many :ahoy_events, class_name: 'Ahoy::Event' belongs_to :user end diff --git a/app/models/vote.rb b/app/models/vote.rb index 5b0e3fe7..9e1c572f 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -1,4 +1,4 @@ -class Vote < ActiveRecord::Base +class Vote < ApplicationRecord belongs_to :user belongs_to :event diff --git a/app/models/vposition.rb b/app/models/vposition.rb index 8a7dbdf9..38ef27fe 100644 --- a/app/models/vposition.rb +++ b/app/models/vposition.rb @@ -1,4 +1,4 @@ -class Vposition < ActiveRecord::Base +class Vposition < ApplicationRecord belongs_to :conference has_many :vchoices diff --git a/app/views/admin/organizations/_form.html.haml b/app/views/admin/organizations/_form.html.haml index c83facbb..048d13e4 100644 --- a/app/views/admin/organizations/_form.html.haml +++ b/app/views/admin/organizations/_form.html.haml @@ -3,7 +3,7 @@ = f.input :name, as: :string, required: true = f.input :description, as: :text, input_html: { rows: 10 }, placeholder: 'Decribe about your organization..' = image_tag f.object.picture.thumb.url if f.object.picture? - - if @organization.picture + - if @organization.picture? = image_tag(@organization.picture.thumb.url, width: '20%') = f.input :picture %p.text-right diff --git a/app/views/organizations/index.html.haml b/app/views/organizations/index.html.haml index bc5a4d5e..c8743363 100644 --- a/app/views/organizations/index.html.haml +++ b/app/views/organizations/index.html.haml @@ -8,7 +8,7 @@ - @organizations.each do |organization| .col-md-4 .thumbnail - = image_tag(organization.picture.thumb.url, width: '20%') + = image_tag(organization.picture.thumb.url, width: '20%') if organization.picture? .caption %h4 = organization.name diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..9ca6ce2b --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby.ruby2.4 +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..c5376b0f --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.ruby2.4 +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..e87a485f --- /dev/null +++ b/bin/setup @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby.ruby2.4 +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..b19460d7 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby.ruby2.4 +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config/application.rb b/config/application.rb index 07ba40f3..4e3844ad 100644 --- a/config/application.rb +++ b/config/application.rb @@ -60,9 +60,6 @@ module Osem # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - # Errors raised within `after_rollback`/`after_commit` propagate normally - # like in other Active Record callbacks. - config.active_record.raise_in_transactional_callbacks = true config.active_job.queue_adapter = :delayed_job end end diff --git a/config/boot.rb b/config/boot.rb index 5e5f0c1f..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..0bbde6f7 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/config/environments/production.rb b/config/environments/production.rb index a70ef729..cf598a16 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -15,7 +15,7 @@ Osem::Application.configure do config.eager_load = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_files = false + config.public_file_server.enabled = false # Compress JavaScripts and CSS config.assets.compress = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 68c74dab..225ae26f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,8 +8,8 @@ Osem::Application.configure do config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.public_file_server.enabled = true + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Do not eager load code on boot. config.eager_load = false diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..51639b67 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..01ef3e66 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# 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' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..1389e86a --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :marshal diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be2..ac033bf9 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,15 +1,16 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end -# + # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e4..dc189968 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 00000000..cbf423a8 --- /dev/null +++ b/config/initializers/new_framework_defaults.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +Rails.application.config.action_controller.raise_on_unfiltered_parameters = true + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = false + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = false + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = false + +# Require `belongs_to` associations by default. Previous versions had false. +Rails.application.config.active_record.belongs_to_required_by_default = false + +# Do not halt callback chains when a callback returns false. Previous versions had true. +ActiveSupport.halt_callback_chains_on_return_false = true diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 00000000..c7f311f8 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,47 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum, this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted this block will be run, if you are using `preload_app!` +# option you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 00000000..c9119b40 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/schema.rb b/db/schema.rb index ea1e3dd7..844b5880 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -14,17 +13,16 @@ ActiveRecord::Schema.define(version: 20170924190528) do create_table "ahoy_events", force: :cascade do |t| - t.uuid "visit_id", limit: 16 + t.binary "visit_id", limit: 16 t.integer "user_id" t.string "name" t.text "properties" t.datetime "time" + t.index ["time"], name: "index_ahoy_events_on_time" + t.index ["user_id"], name: "index_ahoy_events_on_user_id" + t.index ["visit_id"], name: "index_ahoy_events_on_visit_id" end - add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time" - add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id" - add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id" - create_table "answers", force: :cascade do |t| t.string "title" t.datetime "created_at" @@ -37,11 +35,10 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.string "role" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["booth_id"], name: "index_booth_requests_on_booth_id" + t.index ["user_id"], name: "index_booth_requests_on_user_id" end - add_index "booth_requests", ["booth_id"], name: "index_booth_requests_on_booth_id" - add_index "booth_requests", ["user_id"], name: "index_booth_requests_on_user_id" - create_table "booths", force: :cascade do |t| t.string "title" t.text "description" @@ -89,12 +86,11 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.integer "parent_id" t.integer "lft" t.integer "rgt" + t.index ["commentable_id"], name: "index_comments_on_commentable_id" + t.index ["commentable_type"], name: "index_comments_on_commentable_type" + t.index ["user_id"], name: "index_comments_on_user_id" end - add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id" - add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type" - add_index "comments", ["user_id"], name: "index_comments_on_user_id" - create_table "commercials", force: :cascade do |t| t.string "commercial_id" t.string "commercial_type" @@ -130,10 +126,9 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.integer "ticket_layout", default: 0 t.string "custom_domain" t.integer "booth_limit", default: 0 + t.index ["organization_id"], name: "index_conferences_on_organization_id" end - add_index "conferences", ["organization_id"], name: "index_conferences_on_organization_id" - create_table "conferences_questions", id: false, force: :cascade do |t| t.integer "conference_id" t.integer "question_id" @@ -164,10 +159,9 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.string "queue" t.datetime "created_at" t.datetime "updated_at" + t.index ["priority", "run_at"], name: "delayed_jobs_priority" end - add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority" - create_table "difficulty_levels", force: :cascade do |t| t.string "title" t.text "description" @@ -223,13 +217,12 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.datetime "start_time" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true + t.index ["event_id"], name: "index_event_schedules_on_event_id" + t.index ["room_id"], name: "index_event_schedules_on_room_id" + t.index ["schedule_id"], name: "index_event_schedules_on_schedule_id" end - add_index "event_schedules", ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true - add_index "event_schedules", ["event_id"], name: "index_event_schedules_on_event_id" - add_index "event_schedules", ["room_id"], name: "index_event_schedules_on_room_id" - add_index "event_schedules", ["schedule_id"], name: "index_event_schedules_on_schedule_id" - create_table "event_types", force: :cascade do |t| t.string "title", null: false t.integer "length", default: 30 @@ -327,10 +320,9 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "token" + t.index ["token"], name: "index_physical_tickets_on_token", unique: true end - add_index "physical_tickets", ["token"], name: "index_physical_tickets_on_token", unique: true - create_table "programs", force: :cascade do |t| t.integer "conference_id" t.integer "rating", default: 0 @@ -344,10 +336,9 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.datetime "voting_end_date" t.integer "selected_schedule_id" t.integer "schedule_interval", default: 15, null: false + t.index ["selected_schedule_id"], name: "index_programs_on_selected_schedule_id" end - add_index "programs", ["selected_schedule_id"], name: "index_programs_on_selected_schedule_id" - create_table "qanswers", force: :cascade do |t| t.integer "question_id" t.integer "answer_id" @@ -416,11 +407,10 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.string "description" t.integer "resource_id" t.string "resource_type" + t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" + t.index ["name"], name: "index_roles_on_name" end - add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" - add_index "roles", ["name"], name: "index_roles_on_name" - create_table "rooms", force: :cascade do |t| t.string "guid", null: false t.string "name", null: false @@ -433,11 +423,10 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "track_id" + t.index ["program_id"], name: "index_schedules_on_program_id" + t.index ["track_id"], name: "index_schedules_on_track_id" end - add_index "schedules", ["program_id"], name: "index_schedules_on_program_id" - add_index "schedules", ["track_id"], name: "index_schedules_on_track_id" - create_table "splashpages", force: :cascade do |t| t.integer "conference_id" t.boolean "public" @@ -540,12 +529,11 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.date "end_date" t.text "relevance" t.integer "selected_schedule_id" + t.index ["room_id"], name: "index_tracks_on_room_id" + t.index ["selected_schedule_id"], name: "index_tracks_on_selected_schedule_id" + t.index ["submitter_id"], name: "index_tracks_on_submitter_id" end - add_index "tracks", ["room_id"], name: "index_tracks_on_room_id" - add_index "tracks", ["selected_schedule_id"], name: "index_tracks_on_selected_schedule_id" - add_index "tracks", ["submitter_id"], name: "index_tracks_on_submitter_id" - create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -579,20 +567,18 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.boolean "is_admin", default: false t.string "username" t.boolean "is_disabled", default: false + t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["username"], name: "index_users_on_username", unique: true end - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - add_index "users", ["email"], name: "index_users_on_email", unique: true - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - add_index "users", ["username"], name: "index_users_on_username", unique: true - create_table "users_roles", force: :cascade do |t| t.integer "role_id" t.integer "user_id" + t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id" end - add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id" - create_table "vchoices", force: :cascade do |t| t.integer "vday_id" t.integer "vposition_id" @@ -633,12 +619,11 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.text "object_changes" t.datetime "created_at" t.integer "conference_id" + t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" end - add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" - create_table "visits", force: :cascade do |t| - t.uuid "visitor_id", limit: 16 + t.binary "visitor_id", limit: 16 t.string "ip" t.text "user_agent" t.text "referrer" @@ -658,10 +643,9 @@ ActiveRecord::Schema.define(version: 20170924190528) do t.string "utm_content" t.string "utm_campaign" t.datetime "started_at" + t.index ["user_id"], name: "index_visits_on_user_id" end - add_index "visits", ["user_id"], name: "index_visits_on_user_id" - create_table "votes", force: :cascade do |t| t.integer "event_id" t.integer "rating" diff --git a/spec/features/versions_spec.rb b/spec/features/versions_spec.rb index 1bf114a0..37ad4e15 100644 --- a/spec/features/versions_spec.rb +++ b/spec/features/versions_spec.rb @@ -148,7 +148,7 @@ feature 'Version' do visit admin_revision_history_path expect(page).to have_text("Someone (probably via the console) created new ticket Gold with ID #{ticket_id} in conference #{conference.short_title}") - expect(page).to have_text("Someone (probably via the console) updated price cents and description of ticket Gold with ID #{ticket_id} in conference #{conference.short_title}") + expect(page).to have_text("Someone (probably via the console) updated description and price cents of ticket Gold with ID #{ticket_id} in conference #{conference.short_title}") expect(page).to have_text("Someone (probably via the console) deleted ticket Gold with ID #{ticket_id} in conference #{conference.short_title}") end @@ -343,7 +343,7 @@ feature 'Version' do conference.email_settings.update_attributes(registration_subject: 'xxxxx', registration_body: 'yyyyy', accepted_subject: 'zzzzz') visit admin_revision_history_path - expect(page).to have_text("Someone (probably via the console) updated registration subject, registration body and accepted subject + expect(page).to have_text("Someone (probably via the console) updated registration body, registration subject and accepted subject of email settings in conference #{conference.short_title}") end diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb index 62e576f4..ccb1bfbc 100644 --- a/spec/models/program_spec.rb +++ b/spec/models/program_spec.rb @@ -204,6 +204,7 @@ describe Program do program.schedule_interval = 10 program.save! + program.reload expect(program.event_types.pluck(:length).sort).to eq [10, 20, 30] end end