Update to rails 5.2.2.1

This commit is contained in:
Henne Vogelsang 2019-03-26 21:03:23 +01:00
parent 1f30bb8a2f
commit 446808da96
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0
36 changed files with 425 additions and 291 deletions

View file

@ -10,7 +10,7 @@ if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4')
end end
# as web framework # as web framework
gem 'rails', '~> 5.0.7' gem 'rails', '~> 5.2'
# Use Puma as the app server # Use Puma as the app server
gem 'puma', '~> 3.0' gem 'puma', '~> 3.0'
@ -140,7 +140,7 @@ gem 'prawn_rails'
gem 'rqrcode' gem 'rqrcode'
# to render XLS spreadsheets # to render XLS spreadsheets
gem 'axlsx', git: 'https://github.com/randym/axlsx.git' gem 'axlsx'
gem 'axlsx_rails' gem 'axlsx_rails'
# as error catcher # as error catcher
@ -222,6 +222,9 @@ gem 'nokogiri', '>= 1.8.1'
# memcached binary connector # memcached binary connector
gem 'dalli' gem 'dalli'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# Use guard and spring for testing in development # Use guard and spring for testing in development
group :development do group :development do
# to launch specs when files are modified # to launch specs when files are modified

View file

@ -1,39 +1,29 @@
GIT
remote: https://github.com/randym/axlsx.git
revision: c593a08b2a929dac7aa8dc418b55e26b4c49dc34
specs:
axlsx (3.0.0.pre)
htmlentities (~> 4.3, >= 4.3.4)
mimemagic (~> 0.3)
nokogiri (~> 1.8, >= 1.8.2)
rubyzip (~> 1.2, >= 1.2.1)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
remote: https://rails-assets.org/ remote: https://rails-assets.org/
specs: specs:
Ascii85 (1.0.3) Ascii85 (1.0.3)
actioncable (5.0.7.2) actioncable (5.2.2.1)
actionpack (= 5.0.7.2) actionpack (= 5.2.2.1)
nio4r (>= 1.2, < 3.0) nio4r (~> 2.0)
websocket-driver (~> 0.6.1) websocket-driver (>= 0.6.1)
actionmailer (5.0.7.2) actionmailer (5.2.2.1)
actionpack (= 5.0.7.2) actionpack (= 5.2.2.1)
actionview (= 5.0.7.2) actionview (= 5.2.2.1)
activejob (= 5.0.7.2) activejob (= 5.2.2.1)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.0.7.2) actionpack (5.2.2.1)
actionview (= 5.0.7.2) actionview (= 5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7.2) actionview (5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.10.9) active_model_serializers (0.10.9)
@ -41,16 +31,20 @@ GEM
activemodel (>= 4.1, < 6) activemodel (>= 4.1, < 6)
case_transform (>= 0.2) case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3) jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (5.0.7.2) activejob (5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.0.7.2) activemodel (5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
activerecord (5.0.7.2) activerecord (5.2.2.1)
activemodel (= 5.0.7.2) activemodel (= 5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
arel (~> 7.0) arel (>= 9.0)
activesupport (5.0.7.2) activestorage (5.2.2.1)
actionpack (= 5.2.2.1)
activerecord (= 5.2.2.1)
marcel (~> 0.3.1)
activesupport (5.2.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
@ -71,19 +65,26 @@ GEM
railties (>= 4.0) railties (>= 4.0)
archive-zip (0.12.0) archive-zip (0.12.0)
io-like (~> 0.3.0) io-like (~> 0.3.0)
arel (7.1.4) arel (9.0.0)
ast (2.4.0) ast (2.4.0)
autoprefixer-rails (9.5.0) autoprefixer-rails (9.5.0)
execjs execjs
awesome_nested_set (3.1.4) awesome_nested_set (3.1.4)
activerecord (>= 4.0.0, < 5.3) activerecord (>= 4.0.0, < 5.3)
aws_cf_signer (0.1.3) aws_cf_signer (0.1.3)
axlsx (3.0.0.pre)
htmlentities (~> 4.3, >= 4.3.4)
mimemagic (~> 0.3)
nokogiri (~> 1.8, >= 1.8.2)
rubyzip (~> 1.2, >= 1.2.1)
axlsx_rails (0.5.2) axlsx_rails (0.5.2)
actionpack (>= 3.1) actionpack (>= 3.1)
axlsx (>= 2.0.1) axlsx (>= 2.0.1)
bcrypt (3.1.12) bcrypt (3.1.12)
binding_of_caller (0.8.0) binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
bootsnap (1.4.2)
msgpack (~> 1.0)
bootstrap-sass (3.4.1) bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1) autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0) sassc (>= 2.0.0)
@ -169,6 +170,7 @@ GEM
dotenv-rails (2.7.2) dotenv-rails (2.7.2)
dotenv (= 2.7.2) dotenv (= 2.7.2)
railties (>= 3.2, < 6.1) railties (>= 3.2, < 6.1)
erubi (1.8.0)
erubis (2.7.0) erubis (2.7.0)
execjs (2.7.0) execjs (2.7.0)
factory_bot (4.11.1) factory_bot (4.11.1)
@ -276,6 +278,8 @@ GEM
lumberjack (1.0.12) lumberjack (1.0.12)
mail (2.7.1) mail (2.7.1)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.8.2) method_source (0.8.2)
mime-types (3.2.2) mime-types (3.2.2)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
@ -299,6 +303,7 @@ GEM
monetize (~> 1.9.0) monetize (~> 1.9.0)
money (~> 6.13.0) money (~> 6.13.0)
railties (>= 3.0) railties (>= 3.0)
msgpack (1.2.9)
multi_json (1.13.1) multi_json (1.13.1)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
@ -379,19 +384,20 @@ GEM
rack-openid (1.3.1) rack-openid (1.3.1)
rack (>= 1.1.0) rack (>= 1.1.0)
ruby-openid (>= 2.1.8) ruby-openid (>= 2.1.8)
rack-test (0.6.3) rack-test (1.1.0)
rack (>= 1.0) rack (>= 1.0, < 3)
rails (5.0.7.2) rails (5.2.2.1)
actioncable (= 5.0.7.2) actioncable (= 5.2.2.1)
actionmailer (= 5.0.7.2) actionmailer (= 5.2.2.1)
actionpack (= 5.0.7.2) actionpack (= 5.2.2.1)
actionview (= 5.0.7.2) actionview (= 5.2.2.1)
activejob (= 5.0.7.2) activejob (= 5.2.2.1)
activemodel (= 5.0.7.2) activemodel (= 5.2.2.1)
activerecord (= 5.0.7.2) activerecord (= 5.2.2.1)
activesupport (= 5.0.7.2) activestorage (= 5.2.2.1)
activesupport (= 5.2.2.1)
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.0.7.2) railties (= 5.2.2.1)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-assets-bootstrap (3.3.6) rails-assets-bootstrap (3.3.6)
rails-assets-jquery (>= 1.9.1, < 3) rails-assets-jquery (>= 1.9.1, < 3)
@ -425,12 +431,12 @@ GEM
rails-i18n (5.0.4) rails-i18n (5.0.4)
i18n (~> 0.7) i18n (~> 0.7)
railties (~> 5.0) railties (~> 5.0)
railties (5.0.7.2) railties (5.2.2.1)
actionpack (= 5.0.7.2) actionpack (= 5.2.2.1)
activesupport (= 5.0.7.2) activesupport (= 5.2.2.1)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.19.0, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
rake (12.3.2) rake (12.3.2)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
@ -591,7 +597,7 @@ GEM
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff hashdiff
websocket-driver (0.6.5) websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3) websocket-extensions (0.1.3)
whenever (0.10.0) whenever (0.10.0)
@ -611,8 +617,9 @@ DEPENDENCIES
ajax-datatables-rails ajax-datatables-rails
autoprefixer-rails autoprefixer-rails
awesome_nested_set (~> 3.1.3) awesome_nested_set (~> 3.1.3)
axlsx! axlsx
axlsx_rails axlsx_rails
bootsnap (>= 1.1.0)
bootstrap-sass (~> 3.4.0) bootstrap-sass (~> 3.4.0)
bootstrap-switch-rails (~> 3.0.0) bootstrap-switch-rails (~> 3.0.0)
bootstrap3-datetimepicker-rails (~> 4.17.47) bootstrap3-datetimepicker-rails (~> 4.17.47)
@ -671,7 +678,7 @@ DEPENDENCIES
prawn-qrcode (~> 0.3.0) prawn-qrcode (~> 0.3.0)
prawn_rails prawn_rails
puma (~> 3.0) puma (~> 3.0)
rails (~> 5.0.7) rails (~> 5.2)
rails-assets-bootstrap-markdown! rails-assets-bootstrap-markdown!
rails-assets-bootstrap-select! rails-assets-bootstrap-select!
rails-assets-date.format! rails-assets-date.format!
@ -722,4 +729,4 @@ RUBY VERSION
ruby 2.5.0p0 ruby 2.5.0p0
BUNDLED WITH BUNDLED WITH
1.17.1 1.17.3

View file

@ -4,8 +4,7 @@ class BoothRequest < ApplicationRecord
belongs_to :booth belongs_to :booth
belongs_to :user belongs_to :user
validates :role, validates :role, presence: true
presence: true
ROLES = %w[submitter responsible].freeze ROLES = %w[submitter responsible].freeze
end end

View file

@ -94,9 +94,15 @@ class Conference < ApplicationRecord
before_create :add_color before_create :add_color
before_create :create_email_settings before_create :create_email_settings
after_create :create_free_ticket
after_update :delete_event_schedules after_update :delete_event_schedules
after_create do
create_free_ticket
create_contact
create_program
create_roles
end
enum ticket_layout: [:portrait, :landscape] enum ticket_layout: [:portrait, :landscape]
## ##
@ -115,7 +121,7 @@ class Conference < ApplicationRecord
# Delete all EventSchedules that are not in the hours range # Delete all EventSchedules that are not in the hours range
# After the conference has been successfully updated # After the conference has been successfully updated
def delete_event_schedules def delete_event_schedules
if start_hour_changed? || end_hour_changed? if start_hour_previously_changed? || end_hour_previously_changed?
event_schedules = program.event_schedules.select do |event_schedule| event_schedules = program.event_schedules.select do |event_schedule|
event_schedule.start_time.hour < start_hour || event_schedule.start_time.hour < start_hour ||
event_schedule.end_time.hour > end_hour || event_schedule.end_time.hour > end_hour ||
@ -753,12 +759,6 @@ class Conference < ApplicationRecord
((i * big_prime_numbers[component]) % 239 + 16).to_s(16) ((i * big_prime_numbers[component]) % 239 + 16).to_s(16)
end end
after_create do
create_contact
create_program
create_roles
end
## ##
# Creates free ticket for the conference # Creates free ticket for the conference
# after the conference has been successfully created # after the conference has been successfully created
@ -1120,7 +1120,6 @@ class Conference < ApplicationRecord
# #
def create_email_settings def create_email_settings
build_email_settings build_email_settings
true
end end
## ##

View file

@ -3,6 +3,8 @@
class Event < ApplicationRecord class Event < ApplicationRecord
include ActiveRecord::Transitions include ActiveRecord::Transitions
include RevisionCount include RevisionCount
include ActionView::Helpers::NumberHelper
has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id } has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
acts_as_commentable acts_as_commentable

View file

@ -72,8 +72,8 @@ class Program < ApplicationRecord
after_create :create_event_types after_create :create_event_types
after_create :create_difficulty_levels after_create :create_difficulty_levels
after_save :unschedule_unfit_events, if: :schedule_interval_changed? after_save :unschedule_unfit_events, if: :schedule_interval_previously_changed?
after_save :normalize_event_types_length, if: :schedule_interval_changed? after_save :normalize_event_types_length, if: :schedule_interval_previously_changed?
validate :check_languages_format validate :check_languages_format
# Returns all event_schedules for the selected schedule ordered by start_time # Returns all event_schedules for the selected schedule ordered by start_time

View file

@ -76,7 +76,7 @@ class Registration < ApplicationRecord
end end
def registration_limit_not_exceed def registration_limit_not_exceed
if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit if conference.registration_limit > 0 && conference.registrations.reload.count >= conference.registration_limit
errors.add(:base, 'Registration limit exceeded') errors.add(:base, 'Registration limit exceeded')
end end
end end

View file

@ -18,6 +18,6 @@ class Role < ApplicationRecord
# Needed to ensure that removing all user from role doesn't remove role. # Needed to ensure that removing all user from role doesn't remove role.
def cancel def cancel
false throw(:abort)
end end
end end

View file

@ -10,7 +10,7 @@ class SurveyQuestion < ActiveRecord::Base
ICONS = { boolean: 'dot-circle-o', choice: 'check-square-o', string: 'edit', text: 'align-left', datetime: 'clock-o', numeric: 'slack' }.freeze ICONS = { boolean: 'dot-circle-o', choice: 'check-square-o', string: 'edit', text: 'align-left', datetime: 'clock-o', numeric: 'slack' }.freeze
validates :title, presence: true validates :title, presence: true
validates :possible_answers, :max_choices, :min_choices, presence: true, if: 'choice?' validates :possible_answers, :max_choices, :min_choices, presence: true, if: :choice?
validates :min_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true validates :min_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true
validates :max_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true validates :max_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true

View file

@ -11,11 +11,6 @@ class User < ApplicationRecord
# prevent N+1 queries with has_cached_role? by preloading roles *always* # prevent N+1 queries with has_cached_role? by preloading roles *always*
default_scope { preload(:roles) } default_scope { preload(:roles) }
has_many :physical_tickets, through: :ticket_purchases do
def by_conference(conference)
where('ticket_purchases.conference_id = ?', conference)
end
end
has_many :users_roles has_many :users_roles
has_many :roles, through: :users_roles, dependent: :destroy has_many :roles, through: :users_roles, dependent: :destroy
@ -74,6 +69,11 @@ class User < ApplicationRecord
where(conference: conference, registration_ticket: true).first where(conference: conference, registration_ticket: true).first
end end
end end
has_many :physical_tickets, through: :ticket_purchases do
def by_conference(conference)
where('ticket_purchases.conference_id = ?', conference)
end
end
has_many :votes, dependent: :destroy has_many :votes, dependent: :destroy
has_many :voted_events, through: :votes, source: :events has_many :voted_events, through: :votes, source: :events
has_many :subscriptions, dependent: :destroy has_many :subscriptions, dependent: :destroy

View file

@ -1,3 +1,3 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle') load Gem.bin_path('bundler', 'bundle')

View file

@ -1,6 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands' require 'rails/commands'

View file

@ -1,10 +1,9 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = File.expand_path('..', __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
@ -18,6 +17,9 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative' system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml' # cp 'config/database.yml.sample', 'config/database.yml'

View file

@ -1,10 +1,9 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = File.expand_path('..', __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
@ -18,6 +17,9 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative' system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "\n== Updating database ==" puts "\n== Updating database =="
system! 'bin/rails db:migrate' system! 'bin/rails db:migrate'

9
bin/yarn Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
exec 'yarnpkg', *ARGV
rescue Errno::ENOENT
$stderr.puts 'Yarn executable was not detected in the system.'
$stderr.puts 'Download Yarn at https://yarnpkg.com/en/docs/install'
exit 1
end

View file

@ -1,69 +1,19 @@
require File.expand_path('../boot', __FILE__) require_relative 'boot'
require 'rails/all' require 'rails/all'
ActiveSupport::Deprecation.debug = true if Rails.env.test?
include ActionView::Helpers::NumberHelper
if defined?(Bundler) # Require the gems listed in Gemfile, including any gems
# If you precompile assets before deploying to production, use this line # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups(assets: %w(development test))) Bundler.require(*Rails.groups)
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module Osem module Osem
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# 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 = (ENV['OSEM_TIME_ZONE'] || 'UTC')
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = 'utf-8'
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Set cache headers
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' }
config.active_job.queue_adapter = :delayed_job
end end
end end

View file

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

View file

@ -6,4 +6,5 @@ test:
production: production:
adapter: redis adapter: redis
url: <%= ENV['OSEM_REDIS_URL'] %> url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: osem_production

View file

@ -1,5 +1,5 @@
# Load the rails application # Load the Rails application.
require File.expand_path('../application', __FILE__) require_relative 'application'
# Load the configuration file # Load the configuration file
path = Rails.root.join('config', 'config.yml') path = Rails.root.join('config', 'config.yml')
@ -21,5 +21,5 @@ bundle exec rake data:migrate:config2dotenv RAILS_ENV=production
" "
end end
# Initialize the rails application # Initialize the Rails application.
Osem::Application.initialize! Rails.application.initialize!

View file

@ -1,49 +1,67 @@
Osem::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
config.action_mailer.delivery_method = :letter_opener
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development # every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.cache_classes = false
config.cache_store = :memory_store, { size: 64.megabytes }
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise exception on mass assignment protection for Active Record models
# config.active_record.mass_assignment_sanitizer = :strict
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
# Do not eager load code on boot. # Do not eager load code on boot.
config.eager_load = false config.eager_load = false
# Do not log asset requests # Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
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}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Set the detault url for action mailer # Set the detault url for action mailer
config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') } config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') }
# Set the secret key base if it's not set via other means
config.secret_key_base ||= 'f4be765bc98e516de82ac01daa8f8aa11c5ca13cb6c911887851ac89457b6c0b056b2361a21b5c08926c9386e0f91eef84fc0b103d522bf00bc0c78ea8ce7c58'
# Use omniauth mock credentials # Use omniauth mock credentials
OmniAuth.config.test_mode = true OmniAuth.config.test_mode = true
@ -113,5 +131,4 @@ Osem::Application.configure do
devise_config.ichain_test_mode = true devise_config.ichain_test_mode = true
end end
end end
end end

View file

@ -1,62 +1,59 @@
Osem::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests # Code is not reloaded between requests.
config.cache_classes = true config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Eager load code on boot. This eager loads most of Rails and # Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers # your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better. # and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance. # Rake tasks automatically ignore this option for performance.
config.eager_load = true config.eager_load = true
# Disable Rails's static asset server (Apache or nginx will already do this) # Full error reports are disabled and caching is turned on.
config.public_file_server.enabled = false config.consider_all_requests_local = false
# Compress JavaScripts and CSS config.action_controller.perform_caching = true
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
config.assets.compile = false # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Generate digests for assets URLs
config.assets.digest = true
config.assets.css_compressor = :sass
config.assets.js_compressor = :uglifier
config.assets.gzip = true
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = !!ENV['FORCE_SSL']
# See everything in the log (default is :info)
config.log_level = ENV['OSEM_LOG_LEVEL'].try(:to_sym) || :info
# Prepend all log lines with the following tags
config.log_tags = [:uuid]
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
if ENV["RAILS_LOG_TO_STDOUT"].present? # Compress JavaScripts and CSS.
logger = ActiveSupport::Logger.new(STDOUT) config.assets.js_compressor = :uglifier
logger.formatter = config.log_formatter config.assets.css_compressor = :sass
config.logger = ActiveSupport::TaggedLogging.new(logger) config.assets.gzip = true
end
# Use a different cache store in production # Do not fallback to assets pipeline if a precompiled asset is missed.
# config.cache_store = :mem_cache_store config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = !!ENV['FORCE_SSL']
# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
# Use a different cache store in production.
if ENV["OSEM_MEMCACHED_SERVERS"] if ENV["OSEM_MEMCACHED_SERVERS"]
config.cache_store = :mem_cache_store, ENV["OSEM_MEMCACHED_SERVERS"].split(','), { config.cache_store = :mem_cache_store, ENV["OSEM_MEMCACHED_SERVERS"].split(','), {
username: ENV["OSEM_MEMCACHED_USERNAME"], username: ENV["OSEM_MEMCACHED_USERNAME"],
@ -64,25 +61,16 @@ Osem::Application.configure do
} }
end end
# Enable serving of images, stylesheets, and JavaScripts from an asset server # Use a real queuing backend for Active Job (and separate queues per environment)
# config.action_controller.asset_host = "http://assets.example.com" # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "osem_#{Rails.env}"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) config.action_mailer.perform_caching = false
# config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# Set the detault url for action mailer # Set the detault url for action mailer
config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') } config.action_mailer.default_url_options = { host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') }
@ -99,6 +87,30 @@ Osem::Application.configure do
openssl_verify_mode: ENV['OSEM_SMTP_OPENSSL_VERIFY_MODE'] openssl_verify_mode: ENV['OSEM_SMTP_OPENSSL_VERIFY_MODE']
} }
# Set the secret_key_base from the env, if not set by any other means # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
config.secret_key_base ||= ENV["SECRET_KEY_BASE"] # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = ENV['OSEM_LOG_LEVEL'].try(:to_sym) || :info
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end end

View file

@ -1,5 +1,5 @@
Osem::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that # test suite. You never need to work with it otherwise. Remember that
@ -7,42 +7,45 @@ Osem::Application.configure do
# and recreated between test runs. Don't rely on the data there! # and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance # Do not eager load code on boot. This avoids loading your whole application
config.public_file_server.enabled = true # just for the purpose of running a single test. If you are using a tool that
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # preloads Rails for running tests, you may have to set it to true.
# Do not eager load code on boot.
config.eager_load = false config.eager_load = false
# Show full error reports and disable caching # 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}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates # Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory
config.active_storage.service = :test
# Set the default url for action mailer
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Raise exception on mass assignment protection for Active Record models # Print deprecation notices to the stderr.
# config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
# Set the detault url for action mailer # Raises error for missing translations
config.action_mailer.default_url_options = { host: 'localhost:3000' } # config.action_view.raise_on_missing_translations = true
# Do not perform deliveries on test
config.action_mailer.perform_deliveries = false
# Set the secret key base if it's not set via other means
config.secret_key_base ||= 'f4be765bc98e516de82ac01daa8f8aa11c5ca13cb6c911887851ac89457b6c0b056b2361a21b5c08926c9386e0f91eef84fc0b103d522bf00bc0c78ea8ce7c58'
config.after_initialize do config.after_initialize do
ActiveRecord::Base.logger = nil ActiveRecord::Base.logger = nil
@ -51,5 +54,4 @@ Osem::Application.configure do
Timecop.travel(t) Timecop.travel(t)
ActiveSupport::Deprecation.silenced = true ActiveSupport::Deprecation.silenced = true
end end
end end

View file

@ -1,6 +1,8 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!( # ActiveSupport::Reloader.to_prepare do
# http_host: 'example.org', # ApplicationController.renderer.defaults.merge!(
# https: false # http_host: 'example.org',
# ) # https: false
# )
# end

View file

@ -3,9 +3,12 @@
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path # Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in the app/assets
# Rails.application.config.assets.precompile += %w( search.js ) # folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

View file

@ -0,0 +1,2 @@
# Set cache headers
Rails.application.config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' }

View file

@ -0,0 +1,25 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View file

@ -2,4 +2,4 @@
# Specify a serializer for the signed and encrypted cookie jars. # Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid. # Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal Rails.application.config.action_dispatch.cookies_serializer = :json

View file

@ -0,0 +1 @@
Rails.application.config.active_job.queue_adapter = :delayed_job

View file

@ -0,0 +1,2 @@
# Enable escaping HTML in JSON.
Rails.application.config.active_support.escape_html_entities_in_json = true

View file

@ -1,4 +0,0 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View file

@ -19,7 +19,4 @@ Rails.application.config.action_controller.forgery_protection_origin_check = fal
ActiveSupport.to_time_preserves_timezone = false ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false. # Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false ActiveRecord::Base.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

View file

@ -0,0 +1,38 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.2 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.
# Make Active Record use stable #cache_key alongside new #cache_version method.
# This is needed for recyclable cache keys.
# Rails.application.config.active_record.cache_versioning = true
# Use AES-256-GCM authenticated encryption for encrypted cookies.
# Also, embed cookie expiry in signed or encrypted cookies for increased security.
#
# This option is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 5.2.
#
# Existing cookies will be converted on read then written with the new scheme.
# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
# Rails.application.config.active_support.use_authenticated_message_encryption = true
# Add default protection from forgery to ActionController::Base instead of in
# ApplicationController.
# Rails.application.config.action_controller.default_protect_from_forgery = true
# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
# 'f' after migrating old data.
# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
# Rails.application.config.active_support.use_sha1_digests = true
# Make `form_with` generate id attributes for any generated HTML tags.
# Rails.application.config.action_view.form_with_generates_ids = true

View file

@ -0,0 +1,3 @@
# 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.
Rails.application.config.time_zone = (ENV['OSEM_TIME_ZONE'] || 'UTC')

View file

@ -1,8 +1,35 @@
# Sample localization file for English. Add more files in this directory for other locales. # Files in the config/locales directory are used for internationalization
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. # and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en: en:
hello: "Hello world"
time: time:
formats: formats:
short: "%Y-%m-%dT%H:%M:%S" short: "%Y-%m-%dT%H:%M:%S"

View file

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

34
config/storage.yml Normal file
View file

@ -0,0 +1,34 @@
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]