Skip to content

Commit

Permalink
Fix: YAML.load to compatible Ruby 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
matsubara0507 committed Aug 27, 2024
1 parent 4ad0c4c commit 9633e94
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace :turntable do

task :load_config => :rails_env do
yaml_file = File.join(File.dirname(__FILE__), "spec/config/database.yml")
ActiveRecord::Base.configurations = YAML.load ERB.new(IO.read(yaml_file)).result
ActiveRecord::Base.configurations = YAML.safe_load ERB.new(IO.read(yaml_file)).result, permitted_classes: [Symbol], aliases: true
end

desc "create turntable test database"
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/turntable/configuration/loader/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.load(path, env, configuration = Configuration.new)
end

def load(env)
yaml = YAML.load(ERB.new(IO.read(path)).result).with_indifferent_access[env]
yaml = YAML.safe_load(ERB.new(IO.read(path)).result, aliases: true).with_indifferent_access[env]
load_clusters(yaml[:clusters])
load_global_settings(yaml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe ActiveRecord::FixtureSet do
let(:fixtures_root) { File.join(File.dirname(__FILE__), "../../../fixtures") }
let(:fixture_file) { File.join(fixtures_root, "items.yml") }
let(:items) { YAML.load(ERB.new(IO.read(fixture_file)).result) }
let(:items) { YAML.safe_load(ERB.new(IO.read(fixture_file)).result) }

before do
ActiveRecord::FixtureSet.reset_cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:fixture_file) { File.join(fixtures_root, "items.yml") }
let(:test_fixture_class) { Class.new(ActiveSupport::TestCase) { include ActiveRecord::TestFixtures } }
let(:test_fixture) { test_fixture_class.new("test") }
let(:items) { YAML.load(ERB.new(IO.read(fixture_file)).result) }
let(:items) { YAML.safe_load(ERB.new(IO.read(fixture_file)).result) }

describe "#setup_fixtures" do
after do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# in ./support/ and its subdirectories.
database_yaml = File.read(File.join(File.dirname(__FILE__), "config/database.yml"))
database_yaml = ERB.new(database_yaml).result
ActiveRecord::Base.configurations = YAML.load(database_yaml)
ActiveRecord::Base.configurations = YAML.safe_load(database_yaml, aliases: true)
ActiveRecord::Base.establish_connection(:test)

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Expand Down

0 comments on commit 9633e94

Please # to comment.