From 593878185f2a1b6b6e7a78c438292c2e2f543e2a Mon Sep 17 00:00:00 2001 From: tohosaku Date: Sat, 13 Nov 2021 01:46:07 +0000 Subject: [PATCH 2/4] Fix deprecation warning. ActiveRecord::Base.default_timezone= is deprecated and will be removed in Rails 7.1. Use ActiveRecord.default_timezone= instead. Rails 7.1 will return Content-Type header without modification. If you want just the MIME type, please use #media_type instead. Implicit conversion of User into String by ActiveSupport::SafeBuffer is deprecated and will be removed in Rails 7.1. You must explicitly cast it to a String. Support ActiveSupport deprecation see https://github.com/rails/rails/pull/41835 --- app/controllers/attachments_controller.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- app/models/query.rb | 4 ++-- .../custom_fields/_visibility_by_project_selector.html.erb | 2 +- config/application.rb | 3 +++ test/unit/query_test.rb | 4 ++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index aa8bbeec9..65fc019b6 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -100,7 +100,7 @@ class AttachmentsController < ApplicationController def upload # Make sure that API users get used to set this content type # as it won't trigger Rails' automatic parsing of the request body for parameters - unless request.content_type == 'application/octet-stream' + unless request.media_type == 'application/octet-stream' head 406 return end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1dfa26cb2..e43c06b9e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -259,7 +259,7 @@ module ApplicationHelper when 'Array' formatted_objects = object.map {|o| format_object(o, html)} html ? safe_join(formatted_objects, ', ') : formatted_objects.join(', ') - when 'Time' + when 'Time', 'ActiveSupport::TimeWithZone' format_time(object) when 'Date' format_date(object) @@ -631,7 +631,7 @@ module ApplicationHelper 'span', nil, :class => "name icon icon-#{principal.class.name.downcase}" ) - ) + principal + ) + principal.to_s ) end s.html_safe diff --git a/app/models/query.rb b/app/models/query.rb index 0186cc379..ca12cb3f4 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -1581,7 +1581,7 @@ class Query < ActiveRecord::Base else from = from - 1 # second end - if self.class.default_timezone == :utc + if ActiveRecord.default_timezone == :utc from = from.utc end s << ("#{table}.#{field} > '%s'" % [quoted_time(from, is_custom_filter)]) @@ -1590,7 +1590,7 @@ class Query < ActiveRecord::Base if to.is_a?(Date) to = date_for_user_time_zone(to.year, to.month, to.day).end_of_day end - if self.class.default_timezone == :utc + if ActiveRecord.default_timezone == :utc to = to.utc end s << ("#{table}.#{field} <= '%s'" % [quoted_time(to, is_custom_filter)]) diff --git a/app/views/custom_fields/_visibility_by_project_selector.html.erb b/app/views/custom_fields/_visibility_by_project_selector.html.erb index d92e5cdab..25fd4978b 100644 --- a/app/views/custom_fields/_visibility_by_project_selector.html.erb +++ b/app/views/custom_fields/_visibility_by_project_selector.html.erb @@ -4,7 +4,7 @@
<% project_ids = @custom_field.project_ids.to_a %> <%= render_project_nested_lists(Project.all) do |p| - content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, project_ids.include?(p.id), :id => nil) + ' ' + p) + content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, project_ids.include?(p.id), :id => nil) + ' ' + p.to_s) end %> <%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %>
diff --git a/config/application.rb b/config/application.rb index dcad5797b..17c8e8abe 100644 --- a/config/application.rb +++ b/config/application.rb @@ -27,6 +27,9 @@ module RedmineApp # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + config.active_record.legacy_connection_handling = false + config.active_support.remove_deprecated_time_with_zone_name = true + config.active_record.store_full_sti_class = true config.active_record.default_timezone = :local diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index d6f7922a1..3a9655466 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -2610,7 +2610,7 @@ class QueryTest < ActiveSupport::TestCase User.current.pref.update_attribute :time_zone, 'Hawaii' # assume timestamps are stored as utc - ActiveRecord::Base.default_timezone = :utc + ActiveRecord.default_timezone = :utc from = Date.parse '2016-03-20' to = Date.parse '2016-03-22' @@ -2621,7 +2621,7 @@ class QueryTest < ActiveSupport::TestCase t = Time.new(2016, 3, 23, 9, 59, 59, 0).end_of_hour assert_equal "table.field > '#{Query.connection.quoted_date f}' AND table.field <= '#{Query.connection.quoted_date t}'", c ensure - ActiveRecord::Base.default_timezone = :local # restore Redmine default + ActiveRecord.default_timezone = :local # restore Redmine default end def test_project_statement_with_closed_subprojects -- 2.30.2