From 40217f2ba41285c0f15076d93301b18dde64ef48 Mon Sep 17 00:00:00 2001 From: Wanderson Policarpo Date: Tue, 18 Jan 2022 20:26:38 +0000 Subject: [PATCH] Fix YAML load for ruby 3.1. See https://github.com/ruby/psych/pull/487 for more information. --- test/cases/coerced_tests.rb | 3 ++- test/cases/rake_test_sqlserver.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index a76fa354b..29f15edb3 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -1486,7 +1486,8 @@ class YamlSerializationTest < ActiveRecord::TestCase coerce_tests! :test_types_of_virtual_columns_are_not_changed_on_round_trip def test_types_of_virtual_columns_are_not_changed_on_round_trip_coerced author = Author.select("authors.*, 5 as posts_count").first - dumped = YAML.load(YAML.dump(author)) + dumped_author = YAML.dump(author) + dumped = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(dumped_author) : YAML.load(dumped_author) assert_equal 5, author.posts_count assert_equal 5, dumped.posts_count end diff --git a/test/cases/rake_test_sqlserver.rb b/test/cases/rake_test_sqlserver.rb index 1195713d2..0cecf65e9 100644 --- a/test/cases/rake_test_sqlserver.rb +++ b/test/cases/rake_test_sqlserver.rb @@ -176,7 +176,8 @@ class SQLServerRakeSchemaCacheDumpLoadTest < SQLServerRakeTest it "dumps schema cache with SQL Server metadata" do quietly { db_tasks.dump_schema_cache connection, filename } - schema_cache = YAML.load(File.read(filename)) + filedata = File.read(filename) + schema_cache = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(filedata) : YAML.load(filedata) col_id, col_name = connection.schema_cache.columns("users")