From 26ee3c8102548f51223421ba0e73f04125ed5ef6 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Mon, 2 Dec 2024 15:21:56 +0100 Subject: [PATCH 01/10] address deprecations for move to Rails 7.2 --- app/controllers/health_check_controller.rb | 2 +- app/controllers/playback_controller.rb | 4 ++-- spec/rails_helper.rb | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/health_check_controller.rb b/app/controllers/health_check_controller.rb index e800fb18..e9843dc8 100644 --- a/app/controllers/health_check_controller.rb +++ b/app/controllers/health_check_controller.rb @@ -25,6 +25,6 @@ def cache_check def database_check raise 'Database not responding' if defined?(ActiveRecord) && !ActiveRecord::Migrator.current_version - raise 'Pending migrations' unless ActiveRecord::Migration.check_pending!.nil? + raise 'Pending migrations' unless ActiveRecord::Migration.check_all_pending!.nil? end end diff --git a/app/controllers/playback_controller.rb b/app/controllers/playback_controller.rb index 8f87fa2c..bcbe29c8 100644 --- a/app/controllers/playback_controller.rb +++ b/app/controllers/playback_controller.rb @@ -57,7 +57,7 @@ def create_cookie 'sub' => resource_path, 'exp' => expires, } - secret = Rails.application.secrets.secret_key_base + secret = Rails.application.secret_key_base token = JWT.encode(payload, secret, 'HS256') cookies[cookie_name] = { @@ -74,7 +74,7 @@ def verify_cookie raise RecordingNotFoundError if cookie.blank? resource_path = "/#{@playback_format.format}/#{@recording.record_id}" - secret = Rails.application.secrets.secret_key_base + secret = Rails.application.secret_key_base JWT.decode( cookie, secret, diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 261feb1f..8fd5995d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -39,8 +39,12 @@ exit 1 end RSpec.configure do |config| - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = Rails.root.join('spec/fixtures') + # Remove these lines if you're not using ActiveRecord or ActiveRecord fixtures + if respond_to?(:fixture_paths=) # Rails 7.2+ + config.fixture_paths = [Rails.root.join('spec/fixtures')] + else + config.fixture_path = Rails.root.join('spec/fixtures') + end # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 0eb9aa5a16bc10952b936791382c12345908d0a3 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Mon, 2 Dec 2024 17:12:53 +0100 Subject: [PATCH 02/10] workaround to continue using plaintext config/secrets.yml --- app/controllers/playback_controller.rb | 4 ++-- config/application.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/playback_controller.rb b/app/controllers/playback_controller.rb index bcbe29c8..7ba340f9 100644 --- a/app/controllers/playback_controller.rb +++ b/app/controllers/playback_controller.rb @@ -57,7 +57,7 @@ def create_cookie 'sub' => resource_path, 'exp' => expires, } - secret = Rails.application.secret_key_base + secret = Rails.configuration.secrets.secret_key_base token = JWT.encode(payload, secret, 'HS256') cookies[cookie_name] = { @@ -74,7 +74,7 @@ def verify_cookie raise RecordingNotFoundError if cookie.blank? resource_path = "/#{@playback_format.format}/#{@recording.record_id}" - secret = Rails.application.secret_key_base + secret = Rails.configuration.secrets.secret_key_base JWT.decode( cookie, secret, diff --git a/config/application.rb b/config/application.rb index c7efe2bc..77da2ced 100644 --- a/config/application.rb +++ b/config/application.rb @@ -168,5 +168,8 @@ class Application < Rails::Application # Restore default serializer from Rails defaults < 7.1 config.active_record.default_column_serializer = YAML + + # continue using config/secrets.yml for secrets + config.secrets = config_for(:secrets) end end From 9a533634c76e10ba50b2a889481b4ec6644f9004 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Mon, 2 Dec 2024 17:36:51 +0100 Subject: [PATCH 03/10] update to Rails 7.2 --- Gemfile | 2 +- Gemfile.lock | 142 +++++++++++++++++++++---------------------- spec/rails_helper.rb | 6 +- 3 files changed, 73 insertions(+), 77 deletions(-) diff --git a/Gemfile b/Gemfile index 2c5bb14b..3a5b8f16 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '>= 3.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.1' +gem 'rails', '~> 7.2' # Use Puma as the app server gem 'puma', '~> 6.4' diff --git a/Gemfile.lock b/Gemfile.lock index 22e6ba86..18e15200 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,84 +1,82 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.1.4.1) - actionpack (= 7.1.4.1) - activesupport (= 7.1.4.1) + actioncable (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.4.1) - actionpack (= 7.1.4.1) - activejob (= 7.1.4.1) - activerecord (= 7.1.4.1) - activestorage (= 7.1.4.1) - activesupport (= 7.1.4.1) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.4.1) - actionpack (= 7.1.4.1) - actionview (= 7.1.4.1) - activejob (= 7.1.4.1) - activesupport (= 7.1.4.1) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) + actionmailer (7.2.2) + actionpack (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.4.1) - actionview (= 7.1.4.1) - activesupport (= 7.1.4.1) + actionpack (7.2.2) + actionview (= 7.2.2) + activesupport (= 7.2.2) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.4.1) - actionpack (= 7.1.4.1) - activerecord (= 7.1.4.1) - activestorage (= 7.1.4.1) - activesupport (= 7.1.4.1) + useragent (~> 0.16) + actiontext (7.2.2) + actionpack (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.4.1) - activesupport (= 7.1.4.1) + actionview (7.2.2) + activesupport (= 7.2.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.4.1) - activesupport (= 7.1.4.1) + activejob (7.2.2) + activesupport (= 7.2.2) globalid (>= 0.3.6) - activemodel (7.1.4.1) - activesupport (= 7.1.4.1) - activerecord (7.1.4.1) - activemodel (= 7.1.4.1) - activesupport (= 7.1.4.1) + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) timeout (>= 0.4.0) - activestorage (7.1.4.1) - actionpack (= 7.1.4.1) - activejob (= 7.1.4.1) - activerecord (= 7.1.4.1) - activesupport (= 7.1.4.1) + activestorage (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activesupport (= 7.2.2) marcel (~> 1.0) - activesupport (7.1.4.1) + activesupport (7.2.2) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) base64 (0.2.0) + benchmark (0.4.0) bigdecimal (3.1.8) bootsnap (1.16.0) msgpack (~> 1.2) @@ -89,7 +87,7 @@ GEM crack (0.4.5) rexml crass (1.0.6) - date (3.3.4) + date (3.4.1) diff-lcs (1.5.0) dotenv (2.8.1) dotenv-rails (2.8.1) @@ -121,6 +119,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.6.2) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -135,8 +134,7 @@ GEM minitest (5.25.1) minitest-stub_any_instance (1.0.3) msgpack (1.7.0) - mutex_m (0.2.0) - net-imap (0.4.17) + net-imap (0.5.1) date net-protocol net-pop (0.1.2) @@ -167,20 +165,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.4.1) - actioncable (= 7.1.4.1) - actionmailbox (= 7.1.4.1) - actionmailer (= 7.1.4.1) - actionpack (= 7.1.4.1) - actiontext (= 7.1.4.1) - actionview (= 7.1.4.1) - activejob (= 7.1.4.1) - activemodel (= 7.1.4.1) - activerecord (= 7.1.4.1) - activestorage (= 7.1.4.1) - activesupport (= 7.1.4.1) + rails (7.2.2) + actioncable (= 7.2.2) + actionmailbox (= 7.2.2) + actionmailer (= 7.2.2) + actionpack (= 7.2.2) + actiontext (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activemodel (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) bundler (>= 1.15.0) - railties (= 7.1.4.1) + railties (= 7.2.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -192,10 +190,10 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.4.1) - actionpack (= 7.1.4.1) - activesupport (= 7.1.4.1) - irb + railties (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -256,6 +254,7 @@ GEM rubocop (~> 1.33) rubocop-capybara (~> 2.17) ruby-progressbar (1.13.0) + securerandom (0.4.0) spring (4.2.1) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) @@ -267,11 +266,12 @@ GEM tty-screen (= 0.8.1) unicode-display_width (~> 2.2) thor (1.3.2) - timeout (0.4.1) + timeout (0.4.2) tty-screen (0.8.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) + useragent (0.16.10) webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -298,7 +298,7 @@ DEPENDENCIES minitest-stub_any_instance pg (~> 1.4.4) puma (~> 6.4) - rails (~> 7.1) + rails (~> 7.2) rails-controller-testing redis (~> 4.8.0) redis-namespace (~> 1.11.0) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 8fd5995d..db0f8780 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -40,11 +40,7 @@ end RSpec.configure do |config| # Remove these lines if you're not using ActiveRecord or ActiveRecord fixtures - if respond_to?(:fixture_paths=) # Rails 7.2+ - config.fixture_paths = [Rails.root.join('spec/fixtures')] - else - config.fixture_path = Rails.root.join('spec/fixtures') - end + config.fixture_paths << Rails.root.join('spec/fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 4feec0c3879a6715fe98097c4b0c6f8923164efa Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Mon, 2 Dec 2024 21:31:34 +0100 Subject: [PATCH 04/10] update rspec-rails to support the Rails version --- Gemfile | 2 +- Gemfile.lock | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 3a5b8f16..7217dc0c 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,7 @@ group :development, :test do gem 'dotenv-rails' gem 'factory_bot_rails' - gem 'rspec-rails', '~> 5.1.2' + gem 'rspec-rails', '~> 7.1' gem 'rubocop', '~> 1.50.0', require: false gem 'rubocop-performance', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 18e15200..6cc44e7b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,7 +88,7 @@ GEM rexml crass (1.0.6) date (3.4.1) - diff-lcs (1.5.0) + diff-lcs (1.5.1) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -212,23 +212,23 @@ GEM reline (0.5.10) io-console (~> 0.5) rexml (3.3.9) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.5) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.12.0) + rspec-support (~> 3.13.0) + rspec-rails (7.1.0) + actionpack (>= 7.0) + activesupport (>= 7.0) + railties (>= 7.0) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rubocop (1.50.1) json (~> 2.3) parallel (~> 1.10) @@ -302,7 +302,7 @@ DEPENDENCIES rails-controller-testing redis (~> 4.8.0) redis-namespace (~> 1.11.0) - rspec-rails (~> 5.1.2) + rspec-rails (~> 7.1) rubocop (~> 1.50.0) rubocop-performance rubocop-rails (~> 2.19.0) From 6ed89a6b3058ebf2d3ae9a4791a92544413fac9b Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Mon, 2 Dec 2024 21:49:04 +0100 Subject: [PATCH 05/10] update generated RSpec files --- spec/rails_helper.rb | 39 ++++++++++++++++++++++----------------- spec/spec_helper.rb | 2 +- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index db0f8780..4681ebac 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,19 +2,20 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' - ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? +# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file +# that will avoid rails generators crashing because migrations haven't been run yet +# return unless Rails.env.test? require 'rspec/rails' -require 'redis' +# Add additional requires below this line. Rails is not loaded until this point! +require 'redis' # contains helper methods that could be used with any test framework require_relative './support/test_helper' -# Add additional requires below this line. Rails is not loaded until this point! - # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end @@ -28,19 +29,20 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } # Checks for pending migrations and applies them before tests are run. # If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! rescue ActiveRecord::PendingMigrationError => e - puts e.to_s.strip - exit 1 + abort e.to_s.strip end RSpec.configure do |config| - # Remove these lines if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_paths << Rails.root.join('spec/fixtures') + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_paths = [ + Rails.root.join('spec/fixtures') + ] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false @@ -50,24 +52,27 @@ # You can uncomment this line to turn off ActiveRecord support entirely. # config.use_active_record = false - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: + # RSpec Rails uses metadata to mix in different behaviours to your tests, + # for example enabling you to call `get` and `post` in request specs. e.g.: # - # RSpec.describe UsersController, type: :controller do + # RSpec.describe UsersController, type: :request do # # ... # end # # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs + # https://rspec.info/features/7-0/rspec-rails + # + # You can also this infer these behaviours automatically by location, e.g. + # /spec/models would pull in the same behaviour as `type: :model` but this + # behaviour is considered legacy and will be removed in a future version. + # + # To enable this behaviour uncomment the line below. config.infer_spec_type_from_file_location! # Filter lines from Rails gems in backtraces. config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + config.include FactoryBot::Syntax::Methods end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a602e49d..39e391c3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -78,7 +78,7 @@ # # # Limits the available syntax to the non-monkey patched syntax that is # # recommended. For more details, see: - # # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ # config.disable_monkey_patching! # # # Many RSpec users commonly either run the entire suite or an individual From d16d0af54aa6669ce9ff8204138820125f9e89d7 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 3 Dec 2024 10:14:05 +0100 Subject: [PATCH 06/10] merge in changes in Rails 7.2 files generated by rails app:update --- bin/setup | 4 + config/application.rb | 2 +- config/environments/development.rb | 7 +- config/environments/production.rb | 6 ++ config/environments/test.rb | 2 +- .../new_framework_defaults_7_2.rb | 72 ++++++++++++++++++ config/puma.rb | 50 ++++++++---- docs/configuration-README.md | 2 +- public/404.html | 67 ++++++++++++++++ public/406-unsupported-browser.html | 66 ++++++++++++++++ public/422.html | 67 ++++++++++++++++ public/500.html | 66 ++++++++++++++++ public/icon.png | Bin 0 -> 5599 bytes public/icon.svg | 3 + 14 files changed, 391 insertions(+), 23 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_2.rb create mode 100644 public/404.html create mode 100644 public/406-unsupported-browser.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/icon.png create mode 100644 public/icon.svg diff --git a/bin/setup b/bin/setup index b9941564..48dafd56 100755 --- a/bin/setup +++ b/bin/setup @@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do puts "\n== Restarting application server ==" system! 'bin/rails restart' + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/config/application.rb b/config/application.rb index 77da2ced..056562c6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -29,7 +29,7 @@ class Application < Rails::Application # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(tasks)) + config.autoload_lib(ignore: %w[tasks]) # Configuration for the application, engines, and railties goes here. # diff --git a/config/environments/development.rb b/config/environments/development.rb index e508b03d..f9b0b896 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,7 +16,7 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true # Enable/disable caching. By default caching is disabled. @@ -60,15 +60,12 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Raise error when a before_action's only/except options reference missing actions + # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = 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 - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true - config.hosts = nil end diff --git a/config/environments/production.rb b/config/environments/production.rb index 589e75d0..48da47e9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -39,6 +39,9 @@ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = Logger::Formatter.new @@ -75,6 +78,9 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false unless 'true'.casecmp?(ENV['DB_DISABLED']) + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [:id] + # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ # "example.com", # Allow requests from example.com diff --git a/config/environments/test.rb b/config/environments/test.rb index 13ba1a12..2c4c65ff 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -52,7 +52,7 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Raise error when a before_action's only/except options reference missing actions + # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = true # Ensure some dummy configuration is set for testing diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb new file mode 100644 index 00000000..0344a6d0 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_2.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.2 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.2`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# Controls whether Active Job's `#perform_later` and similar methods automatically defer +# the job queuing to after the current Active Record transaction is committed. +# +# Example: +# Topic.transaction do +# topic = Topic.create(...) +# NewTopicNotificationJob.perform_later(topic) +# end +# +# In this example, if the configuration is set to `:never`, the job will +# be enqueued immediately, even though the `Topic` hasn't been committed yet. +# Because of this, if the job is picked up almost immediately, or if the +# transaction doesn't succeed for some reason, the job will fail to find this +# topic in the database. +# +# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter +# will define the behaviour. +# +# Note: Active Job backends can disable this feature. This is generally done by +# backends that use the same database as Active Record as a queue, hence they +# don't need this feature. +#++ +# Rails.application.config.active_job.enqueue_after_transaction_commit = :default + +### +# Adds image/webp to the list of content types Active Storage considers as an image +# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. +# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support +# WebP. Requires imagemagick/libvips built with WebP support. +#++ +# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] + +### +# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError +# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp +# associated with the current time. This is done to prevent forward-dating of migration files, which can +# impact migration generation and other migration commands. +# +# Applications with existing timestamped migrations that do not adhere to the +# expected format can disable validation by setting this config to `false`. +#++ +# Rails.application.config.active_record.validate_migration_timestamps = true + +### +# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. +# +# Example: +# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date +# +# This query used to return a `String`. +#++ +# Rails.application.config.active_record.postgresql_adapter_decode_dates = true + +### +# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are +# deploying to a memory constrained environment you may want to set this to `false`. +#++ +# Rails.application.config.yjit = true diff --git a/config/puma.rb b/config/puma.rb index 015196ab..28113d29 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,30 +1,50 @@ # frozen_string_literal: true -# 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. +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. + +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# to prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # You can either specify `BIND` with a full address (even unix socket) or just `PORT` -bind(ENV.fetch('BIND') { "tcp://0.0.0.0:#{ENV.fetch('PORT', 3000)}" }) +bind(ENV.fetch("BIND") { "tcp://0.0.0.0:#{ENV.fetch('PORT', 3000)}" }) # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV", "development") -# Specifies the `pidfile` that Puma will use. -# pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +# pidfile ENV["PIDFILE"] if ENV["PIDFILE"] + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server 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", 0) # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together @@ -49,5 +69,5 @@ ActiveRecord::Base.establish_connection end -# Allow puma to be restarted by `rails restart` command. +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart diff --git a/docs/configuration-README.md b/docs/configuration-README.md index ae986da0..48112942 100644 --- a/docs/configuration-README.md +++ b/docs/configuration-README.md @@ -29,7 +29,7 @@ These variables are used by the service startup scripts in the Docker images, bu * `BIND`: Instead of setting a port, you can set a URL to bind to. This allows using a Unix socket. See [The Puma documentation](https://puma.io/puma/Puma/DSL.html#bind-instance_method) for details. * `INTERVAL`: Adjust the polling interval (in seconds) for updating server statistics and meeting status. Defaults to 60. Only used by the "poll" task. * `WEB_CONCURRENCY`: The number of processes for the puma web server to fork. A reasonable value is 2 per CPU thread or 1 per 256MB ram, whichever is lower. -* `RAILS_MAX_THREADS`: The number of threads to run in the Rails process. The number of Redis connections in the pool defaults to match this value. The default is 5, a reasonable value for production. +* `RAILS_MAX_THREADS`: The number of threads to run in the Rails process. The number of Redis connections in the pool defaults to match this value. The default is 3, a reasonable value for production. * `RAILS_ENV`: Either `development`, `test`, or `production`. The Docker image defaults to `production`. Rails defaults to `development`. * `BUILD_NUMBER`: An additional build version to report in the BigBlueButton top-level API endpoint. The Docker image has this preset to a value determined at image build time. * `RAILS_LOG_TO_STDOUT`: Log to STDOUT instead of a file. Recommended for deployments with a service manager (e.g. systemd) or in Docker. The Docker image sets this by default. diff --git a/public/404.html b/public/404.html new file mode 100644 index 00000000..2be3af26 --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 00000000..7cf1e168 --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,66 @@ + + + + Your browser is not supported (406) + + + + + + +
+
+

Your browser is not supported.

+

Please upgrade your browser to continue.

+
+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 00000000..c08eac0d --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 00000000..78a030af --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f3b5abcbde91cf6d7a6a26e514eb7e30f476f950 GIT binary patch literal 5599 zcmeHL-D}fO6hCR_taXJlzs3}~RuB=Iujyo=i*=1|1FN%E=zNfMTjru|Q<6v{J{U!C zBEE}?j6I3sz>fzN!6}L_BKjcuASk~1;Dg|U_@d{g?V8mM`~#9U+>>*Ezw>c(PjYWA z4(;!cgge6k5E&d$G5`S-0}!Ik>CV(0Y#1}s-v_gAHhja2=W1?nBAte9D2HG<(+)uj z!5=W4u*{VKMw#{V@^NNs4TClr!FAA%ID-*gc{R%CFKEzG<6gm*9s_uy)oMGW*=nJf zw{(Mau|2FHfXIv6C0@Wk5k)F=3jo1srV-C{pl&k&)4_&JjYrnbJiul}d0^NCSh(#7h=F;3{|>EU>h z6U8_p;^wK6mAB(1b92>5-HxJ~V}@3?G`&Qq-TbJ2(&~-HsH6F#8mFaAG(45eT3VPO zM|(Jd<+;UZs;w>0Qw}0>D%{~r{uo_Fl5_Bo3ABWi zWo^j^_T3dxG6J6fH8X)$a^%TJ#PU!=LxF=#Fd9EvKx_x>q<(KY%+y-08?kN9dXjXK z**Q=yt-FTU*13ouhCdqq-0&;Ke{T3sQU9IdzhV9LhQIpq*P{N)+}|Mh+a-VV=x?R} c>%+pvTcMWshj-umO}|qP?%A)*_KlqT3uEqhU;qFB literal 0 HcmV?d00001 diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 00000000..78307ccd --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + From dd4812d48452b1597143c6326c6dc43c52649176 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 3 Dec 2024 10:46:04 +0100 Subject: [PATCH 07/10] switch to new Rails 7.2 config defaults --- config/application.rb | 2 +- .../new_framework_defaults_7_2.rb | 72 ------------------- 2 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_2.rb diff --git a/config/application.rb b/config/application.rb index 056562c6..dda4ead5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,7 +24,7 @@ module Scalelite class Application < Rails::Application # Initialize configuration defaults - config.load_defaults 7.1 + config.load_defaults 7.2 # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb deleted file mode 100644 index 0344a6d0..00000000 --- a/config/initializers/new_framework_defaults_7_2.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.2 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.2`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Controls whether Active Job's `#perform_later` and similar methods automatically defer -# the job queuing to after the current Active Record transaction is committed. -# -# Example: -# Topic.transaction do -# topic = Topic.create(...) -# NewTopicNotificationJob.perform_later(topic) -# end -# -# In this example, if the configuration is set to `:never`, the job will -# be enqueued immediately, even though the `Topic` hasn't been committed yet. -# Because of this, if the job is picked up almost immediately, or if the -# transaction doesn't succeed for some reason, the job will fail to find this -# topic in the database. -# -# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter -# will define the behaviour. -# -# Note: Active Job backends can disable this feature. This is generally done by -# backends that use the same database as Active Record as a queue, hence they -# don't need this feature. -#++ -# Rails.application.config.active_job.enqueue_after_transaction_commit = :default - -### -# Adds image/webp to the list of content types Active Storage considers as an image -# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. -# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support -# WebP. Requires imagemagick/libvips built with WebP support. -#++ -# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] - -### -# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError -# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp -# associated with the current time. This is done to prevent forward-dating of migration files, which can -# impact migration generation and other migration commands. -# -# Applications with existing timestamped migrations that do not adhere to the -# expected format can disable validation by setting this config to `false`. -#++ -# Rails.application.config.active_record.validate_migration_timestamps = true - -### -# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. -# -# Example: -# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date -# -# This query used to return a `String`. -#++ -# Rails.application.config.active_record.postgresql_adapter_decode_dates = true - -### -# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are -# deploying to a memory constrained environment you may want to set this to `false`. -#++ -# Rails.application.config.yjit = true From e274791e8dc49f1307d6e15cf617ea542e0f55cd Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 3 Dec 2024 11:20:19 +0100 Subject: [PATCH 08/10] update schema.rb --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 8747e577..e2c097a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_06_27_141045) do +ActiveRecord::Schema[7.2].define(version: 2023_06_27_141045) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From fff90d627b1d26a45b8d0e14679844dbb7998991 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 3 Dec 2024 11:55:13 +0100 Subject: [PATCH 09/10] adapt the default pool size in database.yml to match new default puma thread count --- config/database.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.yml b/config/database.yml index a2b830a1..46e57129 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,5 @@ default: &default - pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %> + pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 3 } %> timeout: 5000 adapter: postgresql encoding: unicode From 06e79df94c1074bb4e5aaaf2bbed33e483b96bf4 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 3 Dec 2024 16:27:59 +0100 Subject: [PATCH 10/10] remove superfluous public files --- public/404.html | 67 ---------------------------- public/406-unsupported-browser.html | 66 --------------------------- public/422.html | 67 ---------------------------- public/500.html | 66 --------------------------- public/icon.png | Bin 5599 -> 0 bytes public/icon.svg | 3 -- 6 files changed, 269 deletions(-) delete mode 100644 public/404.html delete mode 100644 public/406-unsupported-browser.html delete mode 100644 public/422.html delete mode 100644 public/500.html delete mode 100644 public/icon.png delete mode 100644 public/icon.svg diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 2be3af26..00000000 --- a/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html deleted file mode 100644 index 7cf1e168..00000000 --- a/public/406-unsupported-browser.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - Your browser is not supported (406) - - - - - - -
-
-

Your browser is not supported.

-

Please upgrade your browser to continue.

-
-
- - diff --git a/public/422.html b/public/422.html deleted file mode 100644 index c08eac0d..00000000 --- a/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index 78a030af..00000000 --- a/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/public/icon.png b/public/icon.png deleted file mode 100644 index f3b5abcbde91cf6d7a6a26e514eb7e30f476f950..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5599 zcmeHL-D}fO6hCR_taXJlzs3}~RuB=Iujyo=i*=1|1FN%E=zNfMTjru|Q<6v{J{U!C zBEE}?j6I3sz>fzN!6}L_BKjcuASk~1;Dg|U_@d{g?V8mM`~#9U+>>*Ezw>c(PjYWA z4(;!cgge6k5E&d$G5`S-0}!Ik>CV(0Y#1}s-v_gAHhja2=W1?nBAte9D2HG<(+)uj z!5=W4u*{VKMw#{V@^NNs4TClr!FAA%ID-*gc{R%CFKEzG<6gm*9s_uy)oMGW*=nJf zw{(Mau|2FHfXIv6C0@Wk5k)F=3jo1srV-C{pl&k&)4_&JjYrnbJiul}d0^NCSh(#7h=F;3{|>EU>h z6U8_p;^wK6mAB(1b92>5-HxJ~V}@3?G`&Qq-TbJ2(&~-HsH6F#8mFaAG(45eT3VPO zM|(Jd<+;UZs;w>0Qw}0>D%{~r{uo_Fl5_Bo3ABWi zWo^j^_T3dxG6J6fH8X)$a^%TJ#PU!=LxF=#Fd9EvKx_x>q<(KY%+y-08?kN9dXjXK z**Q=yt-FTU*13ouhCdqq-0&;Ke{T3sQU9IdzhV9LhQIpq*P{N)+}|Mh+a-VV=x?R} c>%+pvTcMWshj-umO}|qP?%A)*_KlqT3uEqhU;qFB diff --git a/public/icon.svg b/public/icon.svg deleted file mode 100644 index 78307ccd..00000000 --- a/public/icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -