Skip to content

Commit

Permalink
Get tests to pass for Ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Skipants committed Aug 27, 2024
1 parent 49b9b2f commit 3daf13d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
require 'rails/test_help'
require 'minitest/mock'
require 'jsonapi-resources'
require 'pry'
require 'pry-byebug'
require 'memory_profiler'

require File.expand_path('../helpers/value_matchers', __FILE__)
Expand Down Expand Up @@ -80,7 +80,8 @@ class Engine < ::Rails::Engine
# Monkeypatch ActionController::TestCase to delete the RAW_POST_DATA on subsequent calls in the same test.
if Rails::VERSION::MAJOR >= 5
module ClearRawPostHeader
def process(action, *args)
### I THINK THIS IS THE PROBLEM
def process(action, **args)
@request.delete_header 'RAW_POST_DATA'
super
end
Expand All @@ -95,7 +96,7 @@ class ActionController::TestCase
# in a standard way.
if Rails::VERSION::MAJOR < 5
module Rails4ActionControllerProcess
def process(*args)
def process(**args)
if args[2] && args[2][:params]
args[2] = args[2][:params]
end
Expand Down Expand Up @@ -519,14 +520,15 @@ def assert_cacheable_jsonapi_get(url, cached_classes = :all)
end

class ActionController::TestCase
def assert_cacheable_get(action, *args)
def assert_cacheable_get(action, **args)
assert_nil JSONAPI.configuration.resource_cache

normal_queries = []
normal_query_callback = lambda {|_, _, _, _, payload| normal_queries.push payload[:sql] }
ActiveSupport::Notifications.subscribed(normal_query_callback, 'sql.active_record') do
get action, *args
get action, **args
end

non_caching_response = json_response_sans_backtraces
non_caching_status = response.status

Expand Down Expand Up @@ -559,7 +561,7 @@ def assert_cacheable_get(action, *args)
@controller = nil
setup_controller_request_and_response
@request.headers.merge!(orig_request_headers.dup)
get action, *args
get action, **args
end
end
rescue Exception
Expand Down

0 comments on commit 3daf13d

Please sign in to comment.