From afb0220436da43e8a3d9033924f2a9e87464d4e9 Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Mon, 10 Feb 2020 19:12:33 -0400 Subject: [PATCH] Cast `ConfigurationFile#content_path` to a string: - This is required when we assign the `ERB#filename` in case of a Pathname. --- .../lib/active_support/configuration_file.rb | 2 +- activesupport/test/configuration_file_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/configuration_file.rb b/activesupport/lib/active_support/configuration_file.rb index 08eb5a5cd5..7b062efd9b 100644 --- a/activesupport/lib/active_support/configuration_file.rb +++ b/activesupport/lib/active_support/configuration_file.rb @@ -10,7 +10,7 @@ module ActiveSupport class FormatError < StandardError; end def initialize(content_path) - @content_path = content_path + @content_path = content_path.to_s @content = read content_path end diff --git a/activesupport/test/configuration_file_test.rb b/activesupport/test/configuration_file_test.rb index 2d623f6d34..49f83c332b 100644 --- a/activesupport/test/configuration_file_test.rb +++ b/activesupport/test/configuration_file_test.rb @@ -15,4 +15,17 @@ class ConfigurationFileTest < ActiveSupport::TestCase assert_match file.path, error.backtrace.first end end + + test "backtrace contains yaml path (when Pathname given)" do + Tempfile.create do |file| + file.write("wrong: <%= foo %>") + file.rewind + + error = assert_raises do + ActiveSupport::ConfigurationFile.parse(Pathname(file.path)) + end + + assert_match file.path, error.backtrace.first + end + end end