Skip to content

Commit ad7809e

Browse files
authored
Merge branch 'master' into release/v26.1.0
2 parents 3ab8a75 + 779b035 commit ad7809e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

test/test_helper.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ class TestApp < Rails::Application
7878
require 'jsonapi-resources'
7979
require 'pry'
8080

81-
# Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 2.7+
81+
# Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 3.1+
8282
# 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
83+
# 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
8485
require 'psych'
8586

8687
# Patch Psych.load to use unsafe_load in test environment

0 commit comments

Comments
 (0)