From f0d40c945545a53fd1172f20a87e3b32aea938ae Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 11:09:22 +0100 Subject: [PATCH 01/14] Update ruby to 3.3.0 --- .github/workflows/ci.yml | 2 +- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile | 2 +- Gemfile.lock | 10 ++++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f79e3084..427c6e30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 3.3.0 bundler-cache: true - name: Set up Node uses: actions/setup-node@v1 diff --git a/.ruby-version b/.ruby-version index 9e79f6c4..03463f3c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.2.2 +ruby-3.3.0 diff --git a/Dockerfile b/Dockerfile index 8892dbeb..65806c50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use ruby image to build our own image -FROM ruby:3.2.2 +FROM ruby:3.3.0 # Install dependencies RUN apt-get update -qq && apt-get install -y postgresql-client libvips cron \ diff --git a/Gemfile b/Gemfile index f1768a9b..0cf00a85 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '3.2.2' +ruby '3.3.0' # Rails and rails-y stuff gem 'bootsnap', '>= 1.4.4', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 44637435..4228263b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -229,6 +229,7 @@ GEM method_source (1.0.0) mini_magick (4.12.0) mini_mime (1.1.5) + mini_portile2 (2.8.5) minitest (5.19.0) mobility (1.2.9) i18n (>= 0.6.10, < 2) @@ -255,7 +256,8 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -351,7 +353,7 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -414,7 +416,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - singleton (0.1.1) + singleton (0.2.0) snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) @@ -517,7 +519,7 @@ DEPENDENCIES whenever (~> 1.0.0) RUBY VERSION - ruby 3.2.2p53 + ruby 3.3.0p0 BUNDLED WITH 2.3.22 From 3a2d24dacd45479d4362b5fe3fbe69cececcab99 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 11:46:47 +0100 Subject: [PATCH 02/14] Update rails and gems needed to fix deprecation warnings --- Gemfile | 4 +- Gemfile.lock | 212 ++++++++++++---------- app/models/concerns/encryptable.rb | 4 +- app/models/concerns/product_behaviours.rb | 2 +- app/models/order.rb | 2 +- bin/setup | 2 +- config/application.rb | 13 +- config/environments/development.rb | 5 +- config/environments/production.rb | 8 +- config/environments/test.rb | 11 +- 10 files changed, 152 insertions(+), 111 deletions(-) diff --git a/Gemfile b/Gemfile index 0cf00a85..bd72a632 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ ruby '3.3.0' # Rails and rails-y stuff gem 'bootsnap', '>= 1.4.4', require: false -gem 'rails', '~> 7.0.7' +gem 'rails', '~> 7.1.2' # Authentication & Authorization gem 'cancancan', '~> 3.5.0' @@ -33,7 +33,7 @@ gem 'turbo-rails', '~> 1.4.0' # Application structure gem 'active_type', '~> 2.3.0' gem 'inquery', '~> 1.0.9' -gem 'rails_ops', '~> 1.4.0' +gem 'rails_ops', '~> 1.5.0' gem 'schemacop', '~> 3.0.11' # Views diff --git a/Gemfile.lock b/Gemfile.lock index 4228263b..0ece7349 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,87 +20,97 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + actioncable (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + zeitwerk (~> 2.6) + actionmailbox (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.7.2) - actionpack (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionmailer (7.1.2) + actionpack (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activesupport (= 7.1.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.2) + actionview (= 7.1.2) + activesupport (= 7.1.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.7.2) - actionpack (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.2) + actionpack (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (7.1.2) + activesupport (= 7.1.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_storage_validations (1.0.4) activejob (>= 5.2.0) activemodel (>= 5.2.0) activestorage (>= 5.2.0) activesupport (>= 5.2.0) - active_type (2.3.3) + active_type (2.3.4) activerecord (>= 3.2) - activejob (7.0.7.2) - activesupport (= 7.0.7.2) + activejob (7.1.2) + activesupport (= 7.1.2) globalid (>= 0.3.6) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) + activemodel (7.1.2) + activesupport (= 7.1.2) + activerecord (7.1.2) + activemodel (= 7.1.2) + activesupport (= 7.1.2) + timeout (>= 0.4.0) activerecord-session_store (2.0.0) actionpack (>= 5.2.4.1) activerecord (>= 5.2.4.1) multi_json (~> 1.11, >= 1.11.2) rack (>= 2.0.8, < 3) railties (>= 5.2.4.1) - activestorage (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activesupport (= 7.0.7.2) + activestorage (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activesupport (= 7.1.2) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.7.2) + activesupport (7.1.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) ast (2.4.2) base64 (0.1.1) - bcrypt (3.1.19) + bcrypt (3.1.20) + bigdecimal (3.1.5) bootsnap (1.16.0) msgpack (~> 1.2) breadcrumbs_on_rails (4.1.0) @@ -116,13 +126,14 @@ GEM cocoon (1.2.15) coderay (1.1.3) concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) cssbundling-rails (1.2.0) railties (>= 6.0.0) datagrid (1.7.0) railties (>= 6.0) - date (3.3.3) - devise (4.9.2) + date (3.3.4) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) @@ -139,6 +150,8 @@ GEM doorkeeper-openid_connect (1.8.7) doorkeeper (>= 5.5, < 5.7) jwt (>= 2.5) + drb (2.2.0) + ruby2_keywords erubi (1.12.0) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) @@ -162,8 +175,8 @@ GEM text (>= 1.3.0) gettext_i18n_rails (1.12.0) fast_gettext (>= 0.9.0) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) graph_matching (0.1.1) rgl (~> 0.5.0) haml (6.1.2) @@ -195,6 +208,10 @@ GEM activesupport minitest schemacop (~> 3.0.8) + io-console (0.7.1) + irb (1.11.0) + rdoc + reline (>= 0.3.8) jsbundling-rails (1.1.2) railties (>= 6.0.0) json (2.6.3) @@ -217,7 +234,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.3) localhost (1.1.10) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -229,8 +246,7 @@ GEM method_source (1.0.0) mini_magick (4.12.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.19.0) + minitest (5.20.0) mobility (1.2.9) i18n (>= 0.6.10, < 2) request_store (~> 1.0) @@ -246,18 +262,18 @@ GEM msgpack (1.7.2) multi_json (1.15.0) multi_xml (0.6.0) - net-imap (0.3.7) + mutex_m (0.2.0) + net-imap (0.4.9) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4) - mini_portile2 (~> 2.8.2) + nio4r (2.7.0) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -301,31 +317,38 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) + psych (5.1.2) + stringio puma (6.3.1) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.8) rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-protection (3.1.0) rack (~> 2.2, >= 2.2.4) + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.7.2) - actioncable (= 7.0.7.2) - actionmailbox (= 7.0.7.2) - actionmailer (= 7.0.7.2) - actionpack (= 7.0.7.2) - actiontext (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activemodel (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.2) + actioncable (= 7.1.2) + actionmailbox (= 7.1.2) + actionmailer (= 7.1.2) + actionpack (= 7.1.2) + actiontext (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activemodel (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) bundler (>= 1.15.0) - railties (= 7.0.7.2) + railties (= 7.1.2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -339,30 +362,35 @@ GEM rails-settings-cached (2.9.2) activerecord (>= 5.0.0) railties (>= 5.0.0) - rails_ops (1.4.6) + rails_ops (1.5.0) active_type (>= 1.3.0) minitest rails request_store - schemacop (>= 2.4.2, <= 3.1) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) - method_source + schemacop (>= 3.0.0, <= 3.1) + railties (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.6.2) + psych (>= 4.0.0) recaptcha (5.14.0) redcarpet (3.6.0) regexp_parser (2.8.1) + reline (0.4.1) + io-console (~> 0.5) request_store (1.5.1) rack (>= 1.4) - responders (3.1.0) + responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) @@ -400,12 +428,12 @@ GEM ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) - ruby2_keywords (0.0.4) + ruby2_keywords (0.0.5) ruby_parser (3.20.3) sexp_processor (~> 4.16) - schemacop (3.0.24) + schemacop (3.0.28) activesupport (>= 4.0) - ruby2_keywords (= 0.0.4) + ruby2_keywords (>= 0.0.4) sexp_processor (4.17.0) simple_form (5.2.0) actionpack (>= 5.2) @@ -430,12 +458,13 @@ GEM stimulus-rails (1.2.2) railties (>= 6.0.0) stream (0.5.5) + stringio (3.1.0) sysexits (1.2.0) temple (0.10.2) text (1.3.1) - thor (1.2.2) + thor (1.3.0) tilt (2.2.0) - timeout (0.4.0) + timeout (0.4.1) tournament-system (2.1.0) graph_matching (~> 0.1.1) turbo-rails (1.4.0) @@ -448,12 +477,13 @@ GEM version_gem (1.1.3) warden (1.2.9) rack (>= 2.0.9) + webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) whenever (1.0.0) chronic (>= 0.6.3) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS x86_64-linux @@ -497,10 +527,10 @@ DEPENDENCIES pg (~> 1.5.3) pry-byebug (~> 3.9) puma (~> 6.3) - rails (~> 7.0.7) + rails (~> 7.1.2) rails-i18n (~> 7.0.1) rails-settings-cached (~> 2.9.2) - rails_ops (~> 1.4.0) + rails_ops (~> 1.5.0) recaptcha (~> 5.14.0) redcarpet (~> 3.6.0) rqrcode (~> 2.2.0) diff --git a/app/models/concerns/encryptable.rb b/app/models/concerns/encryptable.rb index 86a6a272..150c75c6 100644 --- a/app/models/concerns/encryptable.rb +++ b/app/models/concerns/encryptable.rb @@ -20,14 +20,14 @@ def encryptable_attribute(name, attributes = nil) def encrypt_data(plaintext) len = ActiveSupport::MessageEncryptor.key_len - secret = ENV['SECRET_KEY_BASE'] || Rails.application.secrets.secret_key_base + secret = ENV['SECRET_KEY_BASE'] || Rails.application.credentials.secret_key_base crypt = ActiveSupport::MessageEncryptor.new(secret.first(len)) crypt.encrypt_and_sign(plaintext) end def decrypt_data(ciphertext) len = ActiveSupport::MessageEncryptor.key_len - secret = ENV['SECRET_KEY_BASE'] || Rails.application.secrets.secret_key_base + secret = ENV['SECRET_KEY_BASE'] || Rails.application.credentials.secret_key_base crypt = ActiveSupport::MessageEncryptor.new(secret.first(len)) crypt.decrypt_and_verify(ciphertext) end diff --git a/app/models/concerns/product_behaviours.rb b/app/models/concerns/product_behaviours.rb index c7993c62..3062e440 100644 --- a/app/models/concerns/product_behaviours.rb +++ b/app/models/concerns/product_behaviours.rb @@ -69,7 +69,7 @@ def registered_keys cattr_accessor(:registry) { {} } # Serialize the enabled product behaviours - serialize :enabled_product_behaviours, Array + serialize :enabled_product_behaviours, coder: YAML # We want to run the behaviour validations after the normal validations after_validation :validate_behaviours diff --git a/app/models/order.rb b/app/models/order.rb index 507c2d88..67303887 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -44,7 +44,7 @@ class Order < ApplicationRecord # == Instance Methods ============================================================ def encrypted_base64_id - secret = ENV['SECRET_KEY_BASE'] || Rails.application.secrets.secret_key_base + secret = ENV['SECRET_KEY_BASE'] || Rails.application.credentials.secret_key_base crypt = ActiveSupport::MessageEncryptor.new(secret[0..31]) encrypted_id = crypt.encrypt_and_sign(id) Base64.urlsafe_encode64(encrypted_id) diff --git a/bin/setup b/bin/setup index 57923026..eee68ead 100755 --- a/bin/setup +++ b/bin/setup @@ -5,7 +5,7 @@ require "fileutils" APP_ROOT = File.expand_path('..', __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do diff --git a/config/application.rb b/config/application.rb index fb50b3b6..ff8a7079 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,10 @@ module L4n class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 + + # Load the secret key base from figaro + credentials.secret_key_base = Figaro.env.secret_key_base! # Time tone config.time_zone = 'Bern' @@ -17,9 +20,6 @@ class Application < Rails::Application # We don't want remote forms for now (turbo does not work perfectly without it) config.form_with_generates_remote_forms = false - # We want to be able to add new files while keeping the old ones - config.active_storage.replace_on_assign_to_many = false - # ActiveRecord encryption config.active_record.encryption.primary_key = Figaro.env.ar_primary_key config.active_record.encryption.deterministic_key = Figaro.env.ar_deterministic_key @@ -28,6 +28,11 @@ class Application < Rails::Application # Array holding the payment gateways config.payment_gateways = [] + # 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(assets tasks)) + # Override layouts for Doorkeeper config.to_prepare do # Only Authorized Applications diff --git a/config/environments/development.rb b/config/environments/development.rb index 0d427cae..8d808b7d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ # In the development environment your application's code is reloaded any time # it changes. 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. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -75,5 +75,8 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + config.hosts << 'l4n.local' end diff --git a/config/environments/production.rb b/config/environments/production.rb index 578376c9..540ce46f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -13,11 +13,11 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true # Disable serving static files from the `/public` folder by default since diff --git a/config/environments/test.rb b/config/environments/test.rb index 4d45b2f8..d0cace87 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -9,7 +9,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Turn false under Spring and add config.action_view.cache_template_loading = true - config.cache_classes = true + config.enable_reloading = false # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration @@ -23,12 +23,12 @@ } # 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.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -59,4 +59,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 + config.action_controller.raise_on_missing_callback_actions = true end From ff40df29d34a877c1090aa4bd6c00fca42261a81 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 12:20:00 +0100 Subject: [PATCH 03/14] Keep previously uploaded images on products --- app/views/admin/shop/products/_form.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/admin/shop/products/_form.html.haml b/app/views/admin/shop/products/_form.html.haml index 0e811c3e..b21c7c3d 100644 --- a/app/views/admin/shop/products/_form.html.haml +++ b/app/views/admin/shop/products/_form.html.haml @@ -60,6 +60,7 @@ .form-check = f.check_box :remove_images, { multiple: true }, image.id, nil = f.label :remove_images, _('Product|Remove this image'), for: "product_remove_images_#{image.id}" + = f.hidden_field :images, value: image.signed_id, multiple: true -# -- Variants inputs ----------------------------------------------------------- .card.mb-3 From 3c25531e119ae9fcb5f98850d76aff74c6f46a7c Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 12:23:34 +0100 Subject: [PATCH 04/14] Keep previously uploaded files --- app/controllers/admin/startpage_banners_controller.rb | 6 +++--- app/views/admin/startpage_banners/edit.html.haml | 1 + app/views/admin/tournaments/_form.html.haml | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/startpage_banners_controller.rb b/app/controllers/admin/startpage_banners_controller.rb index 273d42f9..4984c1ef 100644 --- a/app/controllers/admin/startpage_banners_controller.rb +++ b/app/controllers/admin/startpage_banners_controller.rb @@ -14,7 +14,7 @@ def new def create if run Operations::Admin::StartpageBanner::Create flash[:success] = _('Admin|%{model_name}|Successfully created') % { model_name: _('StartpageBanner') } - redirect_to admin_startpage_banners_path + redirect_to admin_startpage_banner_path(model) else add_breadcrumb _('Admin|%{model_name}|Edit') % { model_name: _('StartpageBanner') } flash[:danger] = _('Admin|%{model_name}|Create failed') % { model_name: _('StartpageBanner') } @@ -30,11 +30,11 @@ def edit def update if run Operations::Admin::StartpageBanner::Update flash[:success] = _('Admin|%{model_name}|Successfully updated') % { model_name: _('StartpageBanner') } - redirect_to admin_startpage_banners_path + redirect_to admin_startpage_banner_path(model) else add_breadcrumb _('Admin|%{model_name}|Edit') % { model_name: _('StartpageBanner') } flash[:danger] = _('Admin|%{model_name}|Update failed') % { model_name: _('StartpageBanner') } - render :new, status: :unprocessable_entity + render :update, status: :unprocessable_entity end end diff --git a/app/views/admin/startpage_banners/edit.html.haml b/app/views/admin/startpage_banners/edit.html.haml index 6d68af3d..f1f4c9ac 100644 --- a/app/views/admin/startpage_banners/edit.html.haml +++ b/app/views/admin/startpage_banners/edit.html.haml @@ -20,5 +20,6 @@ .form-check = f.check_box :remove_images, { multiple: true }, image.id, nil = f.label :remove_images, _('StarpageBanner|Remove this image'), for: "startpage_banner_remove_images_#{image.id}" + = f.hidden_field :images, value: image.signed_id, multiple: true .card-footer = f.save diff --git a/app/views/admin/tournaments/_form.html.haml b/app/views/admin/tournaments/_form.html.haml index c010553e..4db843f9 100644 --- a/app/views/admin/tournaments/_form.html.haml +++ b/app/views/admin/tournaments/_form.html.haml @@ -67,6 +67,7 @@ .form-check = f.check_box :remove_files, { multiple: true }, file.id, nil = f.label :remove_files, _('Tournament|Remove this file'), for: "tournament_remove_files_#{file.id}" + = f.hidden_field :files, value: file.signed_id, multiple: true .card.mb-3 .card-header From 0f5f5f0d902a86850babebebad2aefcdbabe107d Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 12:34:35 +0100 Subject: [PATCH 05/14] Comply with rubocop --- config/application.rb | 2 +- payment_gateways/dummy_payment/dummy_payment.gemspec | 4 ++-- payment_gateways/paypal_payment/paypal_payment.gemspec | 4 ++-- payment_gateways/seki_payment/seki_payment.gemspec | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/application.rb b/config/application.rb index ff8a7079..cc7abeb9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,7 +31,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(assets tasks)) + config.autoload_lib(ignore: %w[assets tasks]) # Override layouts for Doorkeeper config.to_prepare do diff --git a/payment_gateways/dummy_payment/dummy_payment.gemspec b/payment_gateways/dummy_payment/dummy_payment.gemspec index 3f334bb2..e377b054 100644 --- a/payment_gateways/dummy_payment/dummy_payment.gemspec +++ b/payment_gateways/dummy_payment/dummy_payment.gemspec @@ -13,12 +13,12 @@ Gem::Specification.new do |spec| spec.metadata['source_code_uri'] = 'https://github.com/Adrian-Hirt/l4n' spec.metadata['changelog_uri'] = 'https://github.com/Adrian-Hirt/l4n' - spec.required_ruby_version = '>= 3.2' + spec.required_ruby_version = '>= 3.3' spec.files = Dir.chdir(File.expand_path(__dir__)) do Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] end - spec.add_dependency 'rails', '>= 7.0.1' + spec.add_dependency 'rails', '>= 7.1.2' spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/payment_gateways/paypal_payment/paypal_payment.gemspec b/payment_gateways/paypal_payment/paypal_payment.gemspec index 1ada83a8..faa538af 100644 --- a/payment_gateways/paypal_payment/paypal_payment.gemspec +++ b/payment_gateways/paypal_payment/paypal_payment.gemspec @@ -13,13 +13,13 @@ Gem::Specification.new do |spec| spec.metadata['source_code_uri'] = 'https://github.com/Adrian-Hirt/l4n' spec.metadata['changelog_uri'] = 'https://github.com/Adrian-Hirt/l4n' - spec.required_ruby_version = '>= 3.2' + spec.required_ruby_version = '>= 3.3' spec.files = Dir.chdir(File.expand_path(__dir__)) do Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] end spec.add_dependency 'httparty' - spec.add_dependency 'rails', '>= 7.0.1' + spec.add_dependency 'rails', '>= 7.1.2' spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/payment_gateways/seki_payment/seki_payment.gemspec b/payment_gateways/seki_payment/seki_payment.gemspec index f4b36ac0..f700fbf4 100644 --- a/payment_gateways/seki_payment/seki_payment.gemspec +++ b/payment_gateways/seki_payment/seki_payment.gemspec @@ -13,12 +13,12 @@ Gem::Specification.new do |spec| spec.metadata['source_code_uri'] = 'https://github.com/Adrian-Hirt/l4n' spec.metadata['changelog_uri'] = 'https://github.com/Adrian-Hirt/l4n' - spec.required_ruby_version = '>= 3.2' + spec.required_ruby_version = '>= 3.3' spec.files = Dir.chdir(File.expand_path(__dir__)) do Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] end - spec.add_dependency 'rails', '>= 7.0.1' + spec.add_dependency 'rails', '>= 7.1.2' spec.metadata['rubygems_mfa_required'] = 'true' end From cc4fb76222aea8b826f65adfbab1fb23ca5d591b Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 12:34:47 +0100 Subject: [PATCH 06/14] Update Gemfile.lock --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0ece7349..24e813b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,20 +2,20 @@ PATH remote: payment_gateways/dummy_payment specs: dummy_payment (1.0.0) - rails (>= 7.0.1) + rails (>= 7.1.2) PATH remote: payment_gateways/paypal_payment specs: paypal_payment (1.1.0) httparty - rails (>= 7.0.1) + rails (>= 7.1.2) PATH remote: payment_gateways/seki_payment specs: seki_payment (1.0.0) - rails (>= 7.0.1) + rails (>= 7.1.2) GEM remote: https://rubygems.org/ From 7efded816b9e432f57f451f4bfb68157ae464075 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 13:27:54 +0100 Subject: [PATCH 07/14] Only load secret key base if it's not loaded yet --- config/application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index cc7abeb9..728b2d94 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,8 +11,8 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.1 - # Load the secret key base from figaro - credentials.secret_key_base = Figaro.env.secret_key_base! + # Load the secret key base from figaro if they're not present yet + credentials.secret_key_base ||= Figaro.env.secret_key_base # Time tone config.time_zone = 'Bern' From b5e34d7043dcee58579660d3d1be6b0388913c9b Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 13:31:08 +0100 Subject: [PATCH 08/14] Remove lib autoloading --- config/application.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/application.rb b/config/application.rb index 728b2d94..e19fa2ce 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,11 +28,6 @@ class Application < Rails::Application # Array holding the payment gateways config.payment_gateways = [] - # 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[assets tasks]) - # Override layouts for Doorkeeper config.to_prepare do # Only Authorized Applications From c95b1c0bcaa75661e9a1f4dec4f3718e378ecc9e Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 13:53:22 +0100 Subject: [PATCH 09/14] Update gems --- Gemfile | 24 +++++----- Gemfile.lock | 125 ++++++++++++++++++++++++++------------------------- 2 files changed, 76 insertions(+), 73 deletions(-) diff --git a/Gemfile b/Gemfile index bd72a632..02bc4fd1 100644 --- a/Gemfile +++ b/Gemfile @@ -12,26 +12,26 @@ gem 'devise', '~> 4.9' gem 'devise-two-factor', '~> 5.0.0' gem 'doorkeeper', '~> 5.6.5' gem 'doorkeeper-openid_connect', '~> 1.8.4' -gem 'recaptcha', '~> 5.14.0' +gem 'recaptcha', '~> 5.16.0' # Session handling -gem 'activerecord-session_store', '~> 2.0.0' +gem 'activerecord-session_store', '~> 2.1.0' # Puma -gem 'puma', '~> 6.3' +gem 'puma', '~> 6.4' # Database gem 'pg', '~> 1.5.3' # Assets -gem 'cssbundling-rails', '~> 1.2.0' -gem 'jsbundling-rails', '~> 1.1.2' +gem 'cssbundling-rails', '~> 1.3.0' +gem 'jsbundling-rails', '~> 1.2.1' gem 'sprockets-rails', '~> 3.4.1' -gem 'stimulus-rails', '~> 1.2.1' -gem 'turbo-rails', '~> 1.4.0' +gem 'stimulus-rails', '~> 1.3.0' +gem 'turbo-rails', '~> 1.5.0' # Application structure -gem 'active_type', '~> 2.3.0' +gem 'active_type', '~> 2.4.0' gem 'inquery', '~> 1.0.9' gem 'rails_ops', '~> 1.5.0' gem 'schemacop', '~> 3.0.11' @@ -39,11 +39,11 @@ gem 'schemacop', '~> 3.0.11' # Views gem 'breadcrumbs_on_rails', '~> 4.1.0' gem 'cocoon', '~> 1.2.15' -gem 'datagrid', '~> 1.7.0' +gem 'datagrid', '~> 1.8.0' gem 'haml-rails', '~> 2.0' gem 'kaminari', '~> 1.2.1' gem 'rqrcode', '~> 2.2.0' -gem 'simple_form', '~> 5.2.0' +gem 'simple_form', '~> 5.3.0' # Translations gem 'gettext_i18n_rails', '~> 1.12.0' @@ -58,7 +58,7 @@ gem 'figaro', '1.2.0' gem 'rails-settings-cached', '~> 2.9.2' # Attachments -gem 'active_storage_validations', '~> 1.0.2' +gem 'active_storage_validations', '~> 1.1.4' gem 'image_processing', '~> 1.12' # Models @@ -95,7 +95,7 @@ group :development do gem 'ruby_parser', require: false # Code analysis and standards - gem 'haml_lint', '~> 0.49.0', require: false + gem 'haml_lint', '~> 0.52.0', require: false gem 'rubocop', '~> 1.24' gem 'rubocop-performance', '~> 1.13' gem 'rubocop-rails', '~> 2.13' diff --git a/Gemfile.lock b/Gemfile.lock index 24e813b9..57f1022a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,12 +69,12 @@ GEM erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - active_storage_validations (1.0.4) + active_storage_validations (1.1.4) activejob (>= 5.2.0) activemodel (>= 5.2.0) activestorage (>= 5.2.0) activesupport (>= 5.2.0) - active_type (2.3.4) + active_type (2.4.0) activerecord (>= 3.2) activejob (7.1.2) activesupport (= 7.1.2) @@ -85,12 +85,13 @@ GEM activemodel (= 7.1.2) activesupport (= 7.1.2) timeout (>= 0.4.0) - activerecord-session_store (2.0.0) - actionpack (>= 5.2.4.1) - activerecord (>= 5.2.4.1) + activerecord-session_store (2.1.0) + actionpack (>= 6.1) + activerecord (>= 6.1) + cgi (>= 0.3.6) multi_json (~> 1.11, >= 1.11.2) - rack (>= 2.0.8, < 3) - railties (>= 5.2.4.1) + rack (>= 2.0.8, < 4) + railties (>= 6.1) activestorage (7.1.2) actionpack (= 7.1.2) activejob (= 7.1.2) @@ -108,10 +109,10 @@ GEM mutex_m tzinfo (~> 2.0) ast (2.4.2) - base64 (0.1.1) + base64 (0.2.0) bcrypt (3.1.20) bigdecimal (3.1.5) - bootsnap (1.16.0) + bootsnap (1.17.0) msgpack (~> 1.2) breadcrumbs_on_rails (4.1.0) railties (>= 5.0) @@ -121,6 +122,7 @@ GEM thor (~> 1.0) byebug (11.1.3) cancancan (3.5.0) + cgi (0.4.1) chronic (0.10.2) chunky_png (1.4.0) cocoon (1.2.15) @@ -128,9 +130,9 @@ GEM concurrent-ruby (1.2.2) connection_pool (2.4.1) crass (1.0.6) - cssbundling-rails (1.2.0) + cssbundling-rails (1.3.3) railties (>= 6.0.0) - datagrid (1.7.0) + datagrid (1.8.0) railties (>= 6.0) date (3.3.4) devise (4.9.3) @@ -145,7 +147,7 @@ GEM railties (~> 7.0) rotp (~> 6.0) docile (1.4.0) - doorkeeper (5.6.6) + doorkeeper (5.6.8) railties (>= 5) doorkeeper-openid_connect (1.8.7) doorkeeper (>= 5.5, < 5.7) @@ -156,18 +158,19 @@ GEM exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) - faker (3.2.1) + faker (3.2.2) i18n (>= 1.8.11, < 2) - faraday (2.7.10) + faraday (2.8.1) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) fast_gettext (2.3.0) - ffi (1.15.5) + ffi (1.16.3) figaro (1.2.0) thor (>= 0.14.0, < 2) forwardable (1.3.3) - gettext (3.4.6) + gettext (3.4.9) erubi locale (>= 2.0.5) prime @@ -179,7 +182,7 @@ GEM activesupport (>= 6.1) graph_matching (0.1.1) rgl (~> 0.5.0) - haml (6.1.2) + haml (6.3.0) temple (>= 0.8.2) thor tilt @@ -188,8 +191,8 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.49.3) - haml (>= 4.0, < 6.2) + haml_lint (0.52.0) + haml (>= 4.0) parallel (~> 1.10) rainbow rubocop (>= 1.0) @@ -203,7 +206,7 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - inquery (1.0.10) + inquery (1.0.11) activerecord activesupport minitest @@ -212,9 +215,9 @@ GEM irb (1.11.0) rdoc reline (>= 0.3.8) - jsbundling-rails (1.1.2) + jsbundling-rails (1.2.1) railties (>= 6.0.0) - json (2.6.3) + json (2.7.1) jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -282,7 +285,7 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - omniauth (2.1.1) + omniauth (2.1.2) hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection @@ -303,11 +306,11 @@ GEM omniauth-openid orm_adapter (0.5.0) pairing_heap (3.0.1) - parallel (1.23.0) - parser (3.2.2.3) + parallel (1.24.0) + parser (3.2.2.4) ast (~> 2.4.1) racc - pg (1.5.3) + pg (1.5.4) prime (0.1.2) forwardable singleton @@ -319,7 +322,7 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - puma (6.3.1) + puma (6.4.0) nio4r (~> 2.0) racc (1.7.3) rack (2.2.8) @@ -356,10 +359,10 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.7) + rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - rails-settings-cached (2.9.2) + rails-settings-cached (2.9.4) activerecord (>= 5.0.0) railties (>= 5.0.0) rails_ops (1.5.0) @@ -383,9 +386,9 @@ GEM ffi (~> 1.0) rdoc (6.6.2) psych (>= 4.0.0) - recaptcha (5.14.0) + recaptcha (5.16.0) redcarpet (3.6.0) - regexp_parser (2.8.1) + regexp_parser (2.8.3) reline (0.4.1) io-console (~> 0.5) request_store (1.5.1) @@ -398,35 +401,35 @@ GEM pairing_heap (>= 0.3.0) rexml (~> 3.2, >= 3.2.4) stream (~> 0.5.3) - rotp (6.2.2) + rotp (6.3.0) rqrcode (2.2.0) chunky_png (~> 1.0) rqrcode_core (~> 1.0) rqrcode_core (1.2.0) - rubocop (1.56.0) - base64 (~> 0.1.1) + rubocop (1.59.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-performance (1.19.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.20.2) + rubocop-performance (1.20.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rails (2.23.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-openid (2.9.2) ruby-progressbar (1.13.0) - ruby-vips (2.1.4) + ruby-vips (2.2.0) ffi (~> 1.12) ruby2_keywords (0.0.5) ruby_parser (3.20.3) @@ -435,7 +438,7 @@ GEM activesupport (>= 4.0) ruby2_keywords (>= 0.0.4) sexp_processor (4.17.0) - simple_form (5.2.0) + simple_form (5.3.0) actionpack (>= 5.2) activemodel (>= 5.2) simplecov (0.22.0) @@ -448,32 +451,32 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - stimulus-rails (1.2.2) + stimulus-rails (1.3.0) railties (>= 6.0.0) stream (0.5.5) stringio (3.1.0) sysexits (1.2.0) - temple (0.10.2) + temple (0.10.3) text (1.3.1) thor (1.3.0) - tilt (2.2.0) + tilt (2.3.0) timeout (0.4.1) tournament-system (2.1.0) graph_matching (~> 0.1.1) - turbo-rails (1.4.0) + turbo-rails (1.5.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) version_gem (1.1.3) warden (1.2.9) rack (>= 2.0.9) @@ -489,16 +492,16 @@ PLATFORMS x86_64-linux DEPENDENCIES - active_storage_validations (~> 1.0.2) - active_type (~> 2.3.0) - activerecord-session_store (~> 2.0.0) + active_storage_validations (~> 1.1.4) + active_type (~> 2.4.0) + activerecord-session_store (~> 2.1.0) bootsnap (>= 1.4.4) breadcrumbs_on_rails (~> 4.1.0) bundler-audit (~> 0.9.0) cancancan (~> 3.5.0) cocoon (~> 1.2.15) - cssbundling-rails (~> 1.2.0) - datagrid (~> 1.7.0) + cssbundling-rails (~> 1.3.0) + datagrid (~> 1.8.0) devise (~> 4.9) devise-two-factor (~> 5.0.0) doorkeeper (~> 5.6.5) @@ -510,10 +513,10 @@ DEPENDENCIES gettext (>= 3.0.2) gettext_i18n_rails (~> 1.12.0) haml-rails (~> 2.0) - haml_lint (~> 0.49.0) + haml_lint (~> 0.52.0) image_processing (~> 1.12) inquery (~> 1.0.9) - jsbundling-rails (~> 1.1.2) + jsbundling-rails (~> 1.2.1) kaminari (~> 1.2.1) listen (~> 3.2) localhost @@ -526,12 +529,12 @@ DEPENDENCIES paypal_payment! pg (~> 1.5.3) pry-byebug (~> 3.9) - puma (~> 6.3) + puma (~> 6.4) rails (~> 7.1.2) rails-i18n (~> 7.0.1) rails-settings-cached (~> 2.9.2) rails_ops (~> 1.5.0) - recaptcha (~> 5.14.0) + recaptcha (~> 5.16.0) redcarpet (~> 3.6.0) rqrcode (~> 2.2.0) rubocop (~> 1.24) @@ -540,12 +543,12 @@ DEPENDENCIES ruby_parser schemacop (~> 3.0.11) seki_payment! - simple_form (~> 5.2.0) + simple_form (~> 5.3.0) simplecov (~> 0.22.0) sprockets-rails (~> 3.4.1) - stimulus-rails (~> 1.2.1) + stimulus-rails (~> 1.3.0) tournament-system (~> 2) - turbo-rails (~> 1.4.0) + turbo-rails (~> 1.5.0) whenever (~> 1.0.0) RUBY VERSION From 80c8bdf8eab2992a5cb4fb1eb9afbbd823b9525c Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 13:56:39 +0100 Subject: [PATCH 10/14] Comply to rubocop & haml-lin --- app/grids/admin/uploads.rb | 2 +- app/helpers/tournament_helper.rb | 4 ++-- app/models/application_record.rb | 2 +- app/models/concerns/encryptable.rb | 2 +- app/models/order.rb | 2 +- app/operations/admin/seat_map/load_seats.rb | 2 +- app/operations/admin/settings/update.rb | 2 +- app/operations/api/v1/event/index.rb | 2 +- app/operations/api/v1/news/index.rb | 2 +- app/operations/lan/seat_map/load_seats.rb | 2 +- app/operations/shop/order/cleanup_untouched.rb | 2 +- app/views/shop/orders/show.html.haml | 2 +- app/views/tournament_teams/index.html.haml | 2 +- app/views/tournament_teams/show.html.haml | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/grids/admin/uploads.rb b/app/grids/admin/uploads.rb index f8df252b..846f5610 100644 --- a/app/grids/admin/uploads.rb +++ b/app/grids/admin/uploads.rb @@ -33,7 +33,7 @@ class Uploads < ApplicationGrid scope.joins(file_attachment: :blob).where(blob: { content_type: value }) end - filter :uploaded_by, :enum, select: User.where(id: Upload.all.select(:user_id)).map { |user| [user.username, user.id] }.sort << ['-', 0], + filter :uploaded_by, :enum, select: User.where(id: Upload.select(:user_id)).map { |user| [user.username, user.id] }.sort << ['-', 0], include_blank: _('Form|Select|Show all') do |value, scope, _grid| if value == '0' scope.where(user_id: nil) diff --git a/app/helpers/tournament_helper.rb b/app/helpers/tournament_helper.rb index bfa72017..710c7eec 100644 --- a/app/helpers/tournament_helper.rb +++ b/app/helpers/tournament_helper.rb @@ -3,7 +3,7 @@ def format_match_score(match, relevant_team) show_score = match.away_score != 0 || match.home_score != 0 team = match.send(relevant_team) - score = match.send("#{relevant_team}_score").to_s + score = match.send(:"#{relevant_team}_score").to_s if match.draw? tag.span(class: 'text-warning') do @@ -26,7 +26,7 @@ def format_match_score_large(match, relevant_team) show_score = match.away_score != 0 || match.home_score != 0 team = match.send(relevant_team) - score = match.send("#{relevant_team}_score").to_s + score = match.send(:"#{relevant_team}_score").to_s # rubocop:disable Lint/DuplicateBranch if match.errors.any? diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 0de7c695..4229d1a9 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -15,7 +15,7 @@ def self.validates_boolean(attribute, **) def self.translate_enums defined_enums.each_key do |key| - define_method "humanized_#{key}" do + define_method :"humanized_#{key}" do _("#{self.class.name}|#{key}|#{send(key)}") end end diff --git a/app/models/concerns/encryptable.rb b/app/models/concerns/encryptable.rb index 150c75c6..19b562a4 100644 --- a/app/models/concerns/encryptable.rb +++ b/app/models/concerns/encryptable.rb @@ -3,7 +3,7 @@ module Encryptable class_methods do def encryptable_attribute(name, attributes = nil) - define_method "encrypted_#{name}" do + define_method :"encrypted_#{name}" do if attributes.nil? data = send(name) elsif attributes.is_a?(Array) diff --git a/app/models/order.rb b/app/models/order.rb index 67303887..33a8d245 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -132,7 +132,7 @@ def remove_address fail 'Wrong status' unless completed? SHIPPING_ADDRESS_FIELDS.each do |field| - public_send("#{field}=", nil) + public_send(:"#{field}=", nil) end end diff --git a/app/operations/admin/seat_map/load_seats.rb b/app/operations/admin/seat_map/load_seats.rb index e7d8db52..399af62f 100644 --- a/app/operations/admin/seat_map/load_seats.rb +++ b/app/operations/admin/seat_map/load_seats.rb @@ -13,7 +13,7 @@ def data seats: [] } - seat_map.seats.includes(:seat_category, ticket: :assignee).each do |seat| + seat_map.seats.includes(:seat_category, ticket: :assignee).find_each do |seat| seat_data = { backendId: seat.id, seatCategoryId: seat.seat_category_id, diff --git a/app/operations/admin/settings/update.rb b/app/operations/admin/settings/update.rb index 7cc3b3ed..ea6b6d11 100644 --- a/app/operations/admin/settings/update.rb +++ b/app/operations/admin/settings/update.rb @@ -42,7 +42,7 @@ def perform entered_values[key] = value if config.valid? - AppConfig.send("#{key}=", value) + AppConfig.send(:"#{key}=", value) else model.errors.merge!(config.errors) end diff --git a/app/operations/api/v1/event/index.rb b/app/operations/api/v1/event/index.rb index 860e0ac9..3dd10743 100644 --- a/app/operations/api/v1/event/index.rb +++ b/app/operations/api/v1/event/index.rb @@ -7,7 +7,7 @@ class Index < RailsOps::Operation def result result = [] - Queries::Event::FetchFutureEvents.run.where(published: true).each do |event| + Queries::Event::FetchFutureEvents.run.where(published: true).find_each do |event| result << { title: event.title, description: event.description, diff --git a/app/operations/api/v1/news/index.rb b/app/operations/api/v1/news/index.rb index 7db2095c..4c0100d5 100644 --- a/app/operations/api/v1/news/index.rb +++ b/app/operations/api/v1/news/index.rb @@ -7,7 +7,7 @@ class Index < RailsOps::Operation def result result = [] - :: NewsPost.where(published: true).each do |news_post| + :: NewsPost.where(published: true).find_each do |news_post| result << { title: news_post.title, content: news_post.content, diff --git a/app/operations/lan/seat_map/load_seats.rb b/app/operations/lan/seat_map/load_seats.rb index ca0028cd..be08de7c 100644 --- a/app/operations/lan/seat_map/load_seats.rb +++ b/app/operations/lan/seat_map/load_seats.rb @@ -13,7 +13,7 @@ def data seats: [] } - seat_map.seats.includes(:seat_category, ticket: :assignee).each do |seat| + seat_map.seats.includes(:seat_category, ticket: :assignee).find_each do |seat| seat_data = { backendId: seat.id, seatCategoryId: seat.seat_category_id, diff --git a/app/operations/shop/order/cleanup_untouched.rb b/app/operations/shop/order/cleanup_untouched.rb index 71c28ad4..86d79435 100644 --- a/app/operations/shop/order/cleanup_untouched.rb +++ b/app/operations/shop/order/cleanup_untouched.rb @@ -7,7 +7,7 @@ class CleanupUntouched < RailsOps::Operation def perform # Delete other orders for user that have status `created` ActiveRecord::Base.transaction do - Order.where(user: context.user, status: 'created').each do |order| + Order.where(user: context.user, status: 'created').find_each do |order| Operations::Shop::Order::CleanupSingleOrder.run order: order end end diff --git a/app/views/shop/orders/show.html.haml b/app/views/shop/orders/show.html.haml index 4dc4498d..24f6286e 100644 --- a/app/views/shop/orders/show.html.haml +++ b/app/views/shop/orders/show.html.haml @@ -48,4 +48,4 @@ %td{ colspan: 3 }= _('Order|Total') %td= money_formatted(model.total) -= op.product_behaviour_hints.join.html_safe # rubocop:disable Rails/OutputSafety += op.product_behaviour_hints.join.html_safe # rubocop:disable Rails/OutputSafety diff --git a/app/views/tournament_teams/index.html.haml b/app/views/tournament_teams/index.html.haml index 8c2d3e40..e1c27be2 100644 --- a/app/views/tournament_teams/index.html.haml +++ b/app/views/tournament_teams/index.html.haml @@ -23,7 +23,7 @@ - if op.teams.none? %tr %td= _('Tournament|No teams') - - op.teams.includes(:users).each do |team| + - op.teams.includes(:users).find_each do |team| %tr %td = link_to team.name, team_path(team) diff --git a/app/views/tournament_teams/show.html.haml b/app/views/tournament_teams/show.html.haml index 8a9f8b8c..58a66700 100644 --- a/app/views/tournament_teams/show.html.haml +++ b/app/views/tournament_teams/show.html.haml @@ -51,7 +51,7 @@ color: :danger -# Then the other users - - model.team_members.includes(:user).each do |team_member| + - model.team_members.includes(:user).find_each do |team_member| - next if team_member.captain? .d-flex.justify-content-between.align-items-center.border-bottom.py-2 From 89ade17c50e1fed0a979b695abe1d88d0e77d4b9 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Sun, 7 Jan 2024 11:19:13 +0100 Subject: [PATCH 11/14] Update gems --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 57f1022a..0fe12e52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,7 +132,7 @@ GEM crass (1.0.6) cssbundling-rails (1.3.3) railties (>= 6.0.0) - datagrid (1.8.0) + datagrid (1.8.1) railties (>= 6.0) date (3.3.4) devise (4.9.3) @@ -266,14 +266,14 @@ GEM multi_json (1.15.0) multi_xml (0.6.0) mutex_m (0.2.0) - net-imap (0.4.9) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) nokogiri (1.16.0-x86_64-linux) @@ -322,7 +322,7 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - puma (6.4.0) + puma (6.4.1) nio4r (~> 2.0) racc (1.7.3) rack (2.2.8) @@ -389,7 +389,7 @@ GEM recaptcha (5.16.0) redcarpet (3.6.0) regexp_parser (2.8.3) - reline (0.4.1) + reline (0.4.2) io-console (~> 0.5) request_store (1.5.1) rack (>= 1.4) @@ -458,7 +458,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - stimulus-rails (1.3.0) + stimulus-rails (1.3.3) railties (>= 6.0.0) stream (0.5.5) stringio (3.1.0) From 4f999073415b47bccd7d82051e2e41052a5e5813 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Sun, 7 Jan 2024 11:39:12 +0100 Subject: [PATCH 12/14] Fix exception --- app/models/order_item.rb | 2 +- app/operations/shop/order/load.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 090b3cad..d56093bc 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -8,7 +8,7 @@ class OrderItem < ApplicationRecord belongs_to :order belongs_to :product_variant, optional: true - delegate :product, to: :product_variant + delegate :product, to: :product_variant, allow_nil: true # == Validations ================================================================= validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: MAX_PERMITTED_INT, integer_only: true } diff --git a/app/operations/shop/order/load.rb b/app/operations/shop/order/load.rb index c802ea59..ee381d5a 100644 --- a/app/operations/shop/order/load.rb +++ b/app/operations/shop/order/load.rb @@ -17,7 +17,7 @@ def model_id_field end def product_behaviour_hints - enabled_product_behaviours = model.order_items.collect { |oi| oi.product.enabled_product_behaviour_classes }.flatten.uniq + enabled_product_behaviours = model.order_items.collect { |oi| oi.product&.enabled_product_behaviour_classes }.flatten.compact.uniq enabled_product_behaviours.map { |behaviour| behaviour.order_show_hint(model) } end From 5eed862a6d1d6ae803a40a1ee9c07cc9fe504175 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Sun, 7 Jan 2024 11:46:14 +0100 Subject: [PATCH 13/14] Add ability to set multiple exception recipients --- DEVELOPMENT.md | 5 ++++- config/initializers/exception_notification.rb | 2 +- docker-compose.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index a99b5567..901dd45e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -41,9 +41,12 @@ variables set as well: For the exception notification: * `ENABLE_EXCEPTION_NOTIFIER` -* `EXCEPTION_NOTIFIER_RECIPIENT` +* `EXCEPTION_NOTIFIER_RECIPIENTS` (optional, only if `ENABLE_EXCEPTION_NOTIFIER` is `true`) * `EXCEPTION_NOTIFIER_SENDER` (optional) +If you want to add more than one recipient, you can pass in a string where the recipients +are delimited by a semicolon `;`, e.g. `"foo@example.com; bar@example.com` + For the devise mailer * `DEVISE_MAIL_SENDER` (optional) diff --git a/config/initializers/exception_notification.rb b/config/initializers/exception_notification.rb index ec6cc55f..81e251f4 100644 --- a/config/initializers/exception_notification.rb +++ b/config/initializers/exception_notification.rb @@ -28,5 +28,5 @@ email: { email_prefix: '[EXCEPTION NOTIFICATION] ', sender_address: sender, - exception_recipients: Figaro.env.exception_notifier_recipient + exception_recipients: Figaro.env.exception_notifier_recipients.split(';').map(&:strip) } diff --git a/docker-compose.yml b/docker-compose.yml index b6bcd9b5..1690655e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -54,7 +54,7 @@ services: DISCORD_BOT_AUTH: ${DISCORD_BOT_AUTH:?err} # Exception notification ENABLE_EXCEPTION_NOTIFIER: ${ENABLE_EXCEPTION_NOTIFIER:-false} - EXCEPTION_NOTIFIER_RECIPIENT: ${EXCEPTION_NOTIFIER_RECIPIENT} + EXCEPTION_NOTIFIER_RECIPIENTS: ${EXCEPTION_NOTIFIER_RECIPIENTS} EXCEPTION_NOTIFIER_SENDER: ${EXCEPTION_NOTIFIER_SENDER} # Devise DEVISE_MAIL_SENDER: ${DEVISE_MAIL_SENDER} From 2de9533fc191c50da545eac6acd188bed37e09e3 Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Sun, 7 Jan 2024 12:38:17 +0100 Subject: [PATCH 14/14] Update changelog for release 1.10.0 --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ config/initializers/version.rb | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de739a2..cb1359b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,37 @@ # Changelog +## 1.10.0 - 2024-01-07 + +### Changed + +* Updated ruby version to `3.3.0` +* Updated gem dependencies + +### Fixed + +* Fixed an exception in the orders show view + +### Added + +* Added ability to set multiple exception recipients + +### Upgrading instructions + +* Rename the env var (e.g. in your `.env` file) `EXCEPTION_NOTIFIER_RECIPIENT` + to `EXCEPTION_NOTIFIER_RECIPIENTS` (now pluralized). You can now set multiple + recipients by setting the variable to a string containing all email addresses, + delimited by a semicolon `;`, e.g. `"foo@example.com; bar@example.com"` + ## 1.9.7 - 2023-12-07 +### Fixed + * Fix a previously introduced bug ## 1.9.6 - 2023-12-07 +### Fixed + * Fix a bug in singleplayer tournament signup ## 1.9.5 - 2023-10-21 diff --git a/config/initializers/version.rb b/config/initializers/version.rb index 6a2dccb8..23b65c8c 100644 --- a/config/initializers/version.rb +++ b/config/initializers/version.rb @@ -1,7 +1,7 @@ module L4N MAJOR = 1 - MINOR = 9 - PATCH = 7 + MINOR = 10 + PATCH = 0 PRE = nil VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.')