Skip to content

Commit

Permalink
upgrade to rails 7.2 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed May 12, 2024
1 parent f89eb62 commit 6007a89
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 101 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "byebug"
gem "debug", platforms: %i[mri windows]
gem "standardrb", "~> 1.0"
gem "standard", ">= 1.35.1"
gem "erb_lint"

gem "kamal"
Expand Down Expand Up @@ -98,7 +98,7 @@ gem "dry-types", "~> 1.7"
gem "avo", ">= 3.2"
gem "ransack", "~> 4.1"

gem 'activerecord-enhancedsqlite3-adapter'
gem "activerecord-enhancedsqlite3-adapter"

# sitepress
gem "sitepress-rails", "~> 4.0"
Expand Down
10 changes: 4 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ GEM
io-console (~> 0.5)
rexml (3.2.6)
rouge (4.2.1)
rubocop (1.63.5)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down Expand Up @@ -476,10 +476,10 @@ GEM
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
standard (1.35.0.1)
standard (1.35.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.62)
rubocop (~> 1.62.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.3)
standard-custom (1.0.2)
Expand All @@ -488,8 +488,6 @@ GEM
standard-performance (1.3.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.20.2)
standardrb (1.0.1)
standard
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
Expand Down Expand Up @@ -573,7 +571,7 @@ DEPENDENCIES
solid_errors
solid_queue (~> 0.2.2)
sqlite3 (~> 1.4)
standardrb (~> 1.0)
standard (>= 1.35.1)
stimulus-rails
turbo-rails (>= 2.0.0.pre.beta.2)
tzinfo-data
Expand Down
4 changes: 2 additions & 2 deletions app/content/helpers/page_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def with(*args, &block)

# Render a block within a layout. This is a useful, and prefered way, to handle
# nesting layouts, within Sitepress.
def render_layout(layout, **, &block)
render(html: capture(&block), layout: "layouts/#{layout}", **)
def render_layout(layout, **, &)
render(html: capture(&), layout: "layouts/#{layout}", **)
end
end
3 changes: 1 addition & 2 deletions app/markdown/application_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def youtube_tag(url, alt)
width: 560,
height: 325,
allow: "encrypted-media; picture-in-picture",
allowfullscreen: true \
do
allowfullscreen: true do
alt
end
end
Expand Down
5 changes: 2 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{2.days.to_i}"}
else
config.action_controller.perform_caching = false

Expand All @@ -41,7 +41,7 @@

config.action_mailer.perform_caching = false

config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
config.action_mailer.default_url_options = {host: "localhost", port: 3000}

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand All @@ -61,7 +61,6 @@
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true


# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

Expand Down
6 changes: 3 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
config.logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
Expand Down
4 changes: 2 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{1.hour.to_i}"}

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand All @@ -43,7 +43,7 @@

# Unlike controllers, the mailer instance doesn't have any context about the
# incoming request so you'll need to provide the :host parameter yourself.
config.action_mailer.default_url_options = { host: "www.example.com" }
config.action_mailer.default_url_options = {host: "www.example.com"}

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Expand Down
68 changes: 68 additions & 0 deletions config/initializers/new_framework_defaults_7_2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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 Active Record will automatically look for inverse relations
# with a pluralized name.
#
# Example:
# class Comment < ActiveRecord::Base
# belongs_to :post
# end
#
# In this example, Active Record will try to infer a `:comment` (singular) association
# on `Post`. With this option enabled, it will also look for a `:comments` association.
#++
# Rails.application.config.active_record.automatically_invert_plural_associations = true
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ def change
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false

t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end

private
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
end
55 changes: 0 additions & 55 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def matches?(request) = false
user: UserConstraint
}

def authenticate(role, &block)
constraints(constraint_for(role), &block)
def authenticate(role, &)
constraints(constraint_for(role), &)
end

private
Expand Down
16 changes: 8 additions & 8 deletions lib/ui_form_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module UiFormHelpers
def ui_text_field(field_name, attributes = {}, &block)
def ui_text_field(field_name, attributes = {}, &)
label = options.delete(:label) { field_name.to_s.humanize }
type = options.delete(:type) { :text }
@template.render Ui::Field::TextComponent.new(field_name, form_builder: self, type: type, label: label, **attributes, &block)
@template.render Ui::Field::TextComponent.new(field_name, form_builder: self, type: type, label: label, **attributes, &)
end

def ui_email_field(field_name, attributes = {}, &block)
def ui_email_field(field_name, attributes = {}, &)
label = options.delete(:label) { field_name.to_s.humanize }
type = options.delete(:type) { :email }
@template.render Ui::Field::TextComponent.new(field_name, form_builder: self, type: type, label: label, autocomplete: "email", **attributes, &block)
@template.render Ui::Field::TextComponent.new(field_name, form_builder: self, type: type, label: label, autocomplete: "email", **attributes, &)
end

def ui_password_field(field_name, attributes = {}, &block)
def ui_password_field(field_name, attributes = {}, &)
label = options.delete(:label) { field_name.to_s.humanize }
type = options.delete(:type) { :password }
@template.render Ui::Field::TextComponent.new(field_name, form_builder: self, label: label, type: type, **attributes), &block
@template.render(Ui::Field::TextComponent.new(field_name, form_builder: self, label: label, type: type, **attributes), &)
end

def ui_text_area(field_name, attributes = {}, &block)
def ui_text_area(field_name, attributes = {}, &)
label = options.delete(:label) { field_name.to_s.humanize }
@template.render Ui::Field::TextAreaComponent.new(field_name, form_builder: self, label: label, **attributes), &block
@template.render(Ui::Field::TextAreaComponent.new(field_name, form_builder: self, label: label, **attributes), &)
end

def ui_submit(value = nil, attributes = {})
Expand Down
12 changes: 6 additions & 6 deletions test/components/back_to_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require "test_helper"

class BackToComponentTest < ViewComponent::TestCase
def test_component_renders_something_useful
# assert_equal(
# %(<span>Hello, components!</span>),
# render_inline(BackToComponent.new(message: "Hello, components!")).css("span").to_html
# )
end
# def test_component_renders_something_useful
# # assert_equal(
# # %(<span>Hello, components!</span>),
# # render_inline(BackToComponent.new(message: "Hello, components!")).css("span").to_html
# # )
# end
end

0 comments on commit 6007a89

Please sign in to comment.