forked from e621ng/e621ng
[Ruby 3] Fix up some deprecations involving ruby 3
Still pending are gems that make poor choices and need to be removed, replaced, or fixed up. Memoist ActiveModelSerializers
This commit is contained in:
parent
e9c1f086ca
commit
436d2aea38
@ -115,7 +115,7 @@ class ApplicationController < ActionController::Base
|
||||
def render_error_page(status, exception, message: exception.message, format: request.format.symbol)
|
||||
@exception = exception
|
||||
@expected = status < 500
|
||||
@message = message.encode("utf-8", { invalid: :replace, undef: :replace })
|
||||
@message = message.encode("utf-8", invalid: :replace, undef: :replace )
|
||||
@backtrace = Rails.backtrace_cleaner.clean(@exception.backtrace)
|
||||
format = :html unless format.in?(%i[html json atom])
|
||||
|
||||
|
@ -62,7 +62,7 @@ class RelatedTagQuery
|
||||
tags_with_categories(tags)
|
||||
end
|
||||
|
||||
def serializable_hash(**options)
|
||||
def serializable_hash(options)
|
||||
{
|
||||
query: query,
|
||||
category: category,
|
||||
|
@ -267,13 +267,13 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
class_methods do
|
||||
def user_status_counter(counter_name, options = {})
|
||||
class_eval do
|
||||
belongs_to :user_status, {foreign_key: :creator_id, primary_key: :user_id, counter_cache: counter_name}.merge(options)
|
||||
belongs_to :user_status, **{foreign_key: :creator_id, primary_key: :user_id, counter_cache: counter_name}.merge(options)
|
||||
end
|
||||
end
|
||||
|
||||
def belongs_to_creator(options = {})
|
||||
class_eval do
|
||||
belongs_to :creator, options.merge(class_name: "User")
|
||||
belongs_to :creator, **options.merge(class_name: "User")
|
||||
before_validation(on: :create) do |rec|
|
||||
if rec.creator_id.nil?
|
||||
rec.creator_id = CurrentUser.id
|
||||
@ -289,7 +289,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
|
||||
def belongs_to_updater(options = {})
|
||||
class_eval do
|
||||
belongs_to :updater, options.merge(class_name: "User")
|
||||
belongs_to :updater, **options.merge(class_name: "User")
|
||||
before_validation do |rec|
|
||||
rec.updater_id = CurrentUser.id
|
||||
rec.updater_ip_addr = CurrentUser.ip_addr if rec.respond_to?(:updater_ip_addr=)
|
||||
|
@ -97,11 +97,11 @@ class Ban < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_user_on_create
|
||||
user.update_attributes(is_banned: true, level: 10)
|
||||
user.update(is_banned: true, level: 10)
|
||||
end
|
||||
|
||||
def update_user_on_destroy
|
||||
user.update_attributes(is_banned: false, level: 20)
|
||||
user.update(is_banned: false, level: 20)
|
||||
end
|
||||
|
||||
def user_name
|
||||
|
@ -1901,7 +1901,7 @@ class Post < ApplicationRecord
|
||||
|
||||
def raw_tag_match(tag)
|
||||
tags = {related: tag.split(' '), include: [], exclude: []}
|
||||
ElasticPostQueryBuilder.new(tag_count: tags[:related].size, tags: tags).build
|
||||
ElasticPostQueryBuilder.new({tag_count: tags[:related].size, tags: tags}).build
|
||||
end
|
||||
|
||||
def tag_match(query)
|
||||
|
@ -26,7 +26,7 @@ class PostPresenter < Presenter
|
||||
|
||||
locals[:article_attrs] = {
|
||||
"id" => "post_#{post.id}",
|
||||
"class" => preview_class(post, options).join(" ")
|
||||
"class" => preview_class(post, **options).join(" ")
|
||||
}.merge(data_attributes(post))
|
||||
|
||||
locals[:link_target] = options[:link_target] || post
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
|
||||
config.cache_classes = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
@ -30,9 +30,6 @@ Rails.application.configure do
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Store uploaded files on the local file system in a temporary directory.
|
||||
config.active_storage.service = :test
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
|
@ -1890,7 +1890,8 @@ CREATE TABLE public.posts (
|
||||
change_seq bigint NOT NULL,
|
||||
tag_count_lore integer DEFAULT 0 NOT NULL,
|
||||
bg_color character varying,
|
||||
generated_samples character varying[]
|
||||
generated_samples character varying[],
|
||||
duration numeric
|
||||
);
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@ FactoryBot.define do
|
||||
image_height { 1000 }
|
||||
file_size { 2000 }
|
||||
rating { "q" }
|
||||
duration { 0.0 }
|
||||
source { FFaker::Internet.http_url }
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,7 @@ FactoryBot.define do
|
||||
"user#{n}"
|
||||
end
|
||||
password { "password" }
|
||||
password_confirmation { "password" }
|
||||
password_hash {"password"}
|
||||
email {FFaker::Internet.email}
|
||||
default_image_size { "large" }
|
||||
|
@ -101,7 +101,7 @@ class ActionDispatch::IntegrationTest
|
||||
|
||||
def method_authenticated(method_name, url, user, options)
|
||||
post session_path, params: { name: user.name, password: user.password }
|
||||
self.send(method_name, url, options)
|
||||
self.send(method_name, url, **options)
|
||||
end
|
||||
|
||||
def get_auth(url, user, options = {})
|
||||
|
Loading…
Reference in New Issue
Block a user