We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 1e810a3 + 355912c commit 779b035Copy full SHA for 779b035
1 file changed
test/test_helper.rb
@@ -78,9 +78,10 @@ class TestApp < Rails::Application
78
require 'jsonapi-resources'
79
require 'pry'
80
81
-# Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 2.7+
+# Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 3.1+
82
# In test environment, allow all classes from YAML (safe for test fixtures)
83
-if defined?(Psych::VERSION) && Psych::VERSION.to_f >= 3.1 && Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR == 0
+# Note: Psych.unsafe_load was added in Psych 4.0 (Ruby 3.1), so we check for its existence
84
+if defined?(Psych::VERSION) && Psych.respond_to?(:unsafe_load) && Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR == 0
85
require 'psych'
86
87
# Patch Psych.load to use unsafe_load in test environment
0 commit comments