diff --git a/Gemfile b/Gemfile index 047f7176c7..96ccd77cb1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,9 @@ source 'https://rubygems.org' # Match ruby version in .ruby-version ruby File.read('.ruby-version') -gem 'rails', '~> 8.0.0' +gem 'rails', '~> 8.1.0' + +gem 'csv' # Keeping old sprockets # https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050 diff --git a/Gemfile.lock b/Gemfile.lock index f87137a109..30d3ad007c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,29 +33,31 @@ GEM GEM remote: https://rubygems.org/ specs: - actioncable (8.0.5.1) - actionpack (= 8.0.5.1) - activesupport (= 8.0.5.1) + action_text-trix (2.1.19) + railties + actioncable (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.5.1) - actionpack (= 8.0.5.1) - activejob (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionmailbox (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) mail (>= 2.8.0) - actionmailer (8.0.5.1) - actionpack (= 8.0.5.1) - actionview (= 8.0.5.1) - activejob (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionmailer (8.1.3) + actionpack (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activesupport (= 8.1.3) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.5.1) - actionview (= 8.0.5.1) - activesupport (= 8.0.5.1) + actionpack (8.1.3) + actionview (= 8.1.3) + activesupport (= 8.1.3) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -63,15 +65,16 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.5.1) - actionpack (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + actiontext (8.1.3) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.5.1) - activesupport (= 8.0.5.1) + actionview (8.1.3) + activesupport (= 8.1.3) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -86,29 +89,29 @@ GEM active_utils (3.6.0) activesupport (>= 4.2) i18n - activejob (8.0.5.1) - activesupport (= 8.0.5.1) + activejob (8.1.3) + activesupport (= 8.1.3) globalid (>= 0.3.6) - activemodel (8.0.5.1) - activesupport (= 8.0.5.1) - activerecord (8.0.5.1) - activemodel (= 8.0.5.1) - activesupport (= 8.0.5.1) + activemodel (8.1.3) + activesupport (= 8.1.3) + activerecord (8.1.3) + activemodel (= 8.1.3) + activesupport (= 8.1.3) timeout (>= 0.4.0) - activestorage (8.0.5.1) - actionpack (= 8.0.5.1) - activejob (= 8.0.5.1) - activerecord (= 8.0.5.1) - activesupport (= 8.0.5.1) + activestorage (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activesupport (= 8.1.3) marcel (~> 1.0) - activesupport (8.0.5.1) + activesupport (8.1.3) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) @@ -146,7 +149,6 @@ GEM axe-core-api (= 4.12.0) base64 (0.3.0) bcrypt (3.1.22) - benchmark (0.5.0) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -499,20 +501,20 @@ GEM rackup (1.0.1) rack (< 3) webrick - rails (8.0.5.1) - actioncable (= 8.0.5.1) - actionmailbox (= 8.0.5.1) - actionmailer (= 8.0.5.1) - actionpack (= 8.0.5.1) - actiontext (= 8.0.5.1) - actionview (= 8.0.5.1) - activejob (= 8.0.5.1) - activemodel (= 8.0.5.1) - activerecord (= 8.0.5.1) - activestorage (= 8.0.5.1) - activesupport (= 8.0.5.1) + rails (8.1.3) + actioncable (= 8.1.3) + actionmailbox (= 8.1.3) + actionmailer (= 8.1.3) + actionpack (= 8.1.3) + actiontext (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activemodel (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) bundler (>= 1.15.0) - railties (= 8.0.5.1) + railties (= 8.1.3) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -532,9 +534,9 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (8.0.5.1) - actionpack (= 8.0.5.1) - activesupport (= 8.0.5.1) + railties (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -779,6 +781,7 @@ DEPENDENCIES comfortable_mexican_sofa! connection_pool (< 3) crowdin-cli + csv csv_shaper dalli database_cleaner @@ -828,7 +831,7 @@ DEPENDENCIES rack-attack rack-cors rack-protection (>= 2.0.1) - rails (~> 8.0.0) + rails (~> 8.1.0) rails-assets-leaflet.markercluster! rails-controller-testing rails_12factor diff --git a/config/application.rb b/config/application.rb index bc2dd592a1..ac0cc467c1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,7 +14,7 @@ module Growstuff class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 8.0 + config.load_defaults 8.1 # Rails 7.1+ requires a coder for `serialize`. # We set YAML as the default for compatibility with gems like Mexican Sofa. diff --git a/config/initializers/jsonapi_resources_patch.rb b/config/initializers/jsonapi_resources_patch.rb new file mode 100644 index 0000000000..0b700f59cf --- /dev/null +++ b/config/initializers/jsonapi_resources_patch.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# JSONAPI::Resources (0.10.7) is currently incompatible with Rails 8.1 +# because ActionDispatch::Routing::Mapper::Resources::Resource.initialize now expects keyword arguments for only/except. +# This patch ensures that it passes keyword arguments correctly. +# Remove when https://github.com/JSONAPI-Resources/jsonapi-resources/issues/1488 is fixed + +if defined?(JSONAPI) + module ActionDispatch + module Routing + class Mapper + module Resources + class Resource + alias_method :original_initialize, :initialize + + def initialize(entities, api_only, shallow, options = {}) + # In Rails 8.1, initialize(entities, api_only, shallow, only: nil, except: nil, **options) + # and jsonapi-resources passes them in the options hash. + if options.is_a?(Hash) + only = options.delete(:only) + except = options.delete(:except) + original_initialize(entities, api_only, shallow, only: only, except: except, **options) + else + original_initialize(entities, api_only, shallow, options) + end + end + end + end + end + end + end + + module JSONAPI + module RoutingExt + module Mapper + def jsonapi_resource_scope(resource, resource_type) + # The original implementation uses Resource.new which we patched above. + # We need to make sure we don't break Rails 5/6/7/8 logic if it were to run there. + @scope = @scope.new(scope_level_resource: resource, jsonapi_resource: resource_type) + + controller(resource.resource_scope) { yield } + ensure + @scope = @scope.parent + end + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c14ef865e..de08a53e14 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -58,7 +58,9 @@ def index_everything config.around(:each, :search) do |example| Searchkick.callbacks(true) do index_everything + example.run + index_everything end end