From 3f920f0168f2a8f120e728d775b73c2a9281fb5f Mon Sep 17 00:00:00 2001 From: Takashi Kato Date: Mon, 14 Mar 2022 14:25:24 +0000 Subject: [PATCH 1/4] Upgrade to Rails 7 --- Gemfile | 19 ++++++------ config/application.rb | 3 -- config/initializers/10-patches.rb | 43 +++++++++++++++++++--------- test/application_system_test_case.rb | 2 +- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index c9d9af50c..aea677019 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,18 @@ source 'https://rubygems.org' -ruby '>= 2.5.0', '< 3.2.0' +ruby '>= 2.7.0', '< 3.2.0' gem 'bundler', '>= 1.12.0' -gem 'rails', '6.1.5' -gem 'globalid', '~> 0.4.2' if Gem.ruby_version < Gem::Version.new('2.6.0') +gem 'rails', '7.0.2.3' gem 'rouge', '~> 3.28.0' gem 'request_store', '~> 1.5.0' gem 'mini_mime', '~> 1.1.0' -gem "actionpack-xml_parser" -gem 'roadie-rails', (Gem.ruby_version < Gem::Version.new('2.6.0') ? '~> 2.2.0' : '~> 3.0.0') +gem "actionpack-xml_parser", '2.0.1' +gem 'roadie-rails', '~> 3.0.0' gem 'marcel' gem "mail", "~> 2.7.1" gem 'csv', '~> 3.2.0' -gem 'nokogiri', (Gem.ruby_version < Gem::Version.new('2.6.0') ? '~> 1.12.2' : '~> 1.13.0') +gem 'nokogiri', '~> 1.13.0' gem 'i18n', '~> 1.10.0' gem "rbpdf", "~> 1.20.0" gem 'addressable' @@ -47,7 +46,7 @@ end # Optional CommonMark support, not for JRuby group :common_mark do gem "html-pipeline", "~> 2.13.2" - gem "commonmarker", (Gem.ruby_version < Gem::Version.new('2.6.0') ? '0.21.0' : '0.23.1') + gem "commonmarker", '0.23.1' gem "sanitize", "~> 6.0" gem 'deckar01-task_list', '2.3.2' end @@ -96,9 +95,9 @@ group :test do gem "ffi", platforms: [:mingw, :x64_mingw, :mswin] # For running system tests gem 'puma' - gem 'capybara', (Gem.ruby_version < Gem::Version.new('2.6.0') ? '~> 3.35.3' : '~> 3.36.0') - gem "selenium-webdriver", "~> 3.142.7" - gem 'webdrivers', '4.6.1', require: false + gem 'capybara', '~> 3.36.0' + gem "selenium-webdriver", "~> 4.1.0" + gem 'webdrivers', '~> 5.0.0', require: false # RuboCop gem 'rubocop', '~> 1.27.0' gem 'rubocop-performance', '~> 1.13.0' diff --git a/config/application.rb b/config/application.rb index bba468f38..dcad5797b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,9 +23,6 @@ module RedmineApp # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # Custom directories with classes and modules you want to be autoloadable. - config.autoloader = :zeitwerk - # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 0e01e28a5..9c1bcb680 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -47,20 +47,6 @@ module ActionView end end end - - class Resolver - def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[]) - locals = locals.map(&:to_s).sort!.freeze - - cached(key, [name, prefix, partial], details, locals) do - if (details[:formats] & [:xml, :json]).any? - details = details.dup - details[:formats] = details[:formats].dup + [:api] - end - _find_all(name, prefix, partial, details, key, locals) - end - end - end end ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe } @@ -144,6 +130,35 @@ module ActionController end end +module ActionView + LookupContext.prepend(Module.new do + def formats=(values) + if (Array(values) & [:xml, :json]).any? + values << :api + end + super values + end + end) + + Rendering.prepend(Module.new do + def rendered_format + if lookup_context.formats.first == :api + return request.format + end + + super + end + end) + + class Template + Types.singleton_class.prepend(Module.new do + def symbols + super + [:api] + end + end) + end +end + # Adds asset_id parameters to assets like Rails 3 to invalidate caches in browser module ActionView module Helpers diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d813f0ce3..39650f529 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -34,7 +34,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase options = {} # Allow running tests using a remote Selenium hub options[:url] = ENV['SELENIUM_REMOTE_URL'] if ENV['SELENIUM_REMOTE_URL'] - options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( + options[:capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( 'goog:chromeOptions' => { 'args' => GOOGLE_CHROME_OPTS_ARGS, 'prefs' => { -- 2.30.2