diff options
author | Andrew Kreiling <agkr@pobox.com> | 2013-03-03 07:50:59 -0600 |
---|---|---|
committer | Alex Tambellini <atambellini@gmail.com> | 2013-06-09 18:20:10 -0400 |
commit | a548792aa0beef4330a3d47eb75dd2fe741013bc (patch) | |
tree | 73c25e049f42333dbaff3a1a95c0153ccacbd11f /activesupport/test | |
parent | f5e133e830940731b74c4e12118eab90054d32ec (diff) | |
download | rails-a548792aa0beef4330a3d47eb75dd2fe741013bc.tar.gz rails-a548792aa0beef4330a3d47eb75dd2fe741013bc.tar.bz2 rails-a548792aa0beef4330a3d47eb75dd2fe741013bc.zip |
Don't blindly call blame_file! on exceptions in ActiveSupport::Dependencies::Loadable
It is possible under some environments to receive an Exception that is
not extended with Blamable (e.g. JRuby).
ActiveSupport::Dependencies::Loadable#load_dependency blindly call
blame_file! on the exception which throws it's own NoMethodError
exception and hides the original Exception.
This commit fixes #9521
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/dependencies/raises_exception_without_blame_file.rb | 5 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/dependencies/raises_exception_without_blame_file.rb b/activesupport/test/dependencies/raises_exception_without_blame_file.rb new file mode 100644 index 0000000000..4b2da6ff30 --- /dev/null +++ b/activesupport/test/dependencies/raises_exception_without_blame_file.rb @@ -0,0 +1,5 @@ +exception = Exception.new('I am not blamable!') +class << exception + undef_method(:blame_file!) +end +raise exception diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 4b1426bb2e..68b6cc6e8c 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -76,6 +76,14 @@ class DependenciesTest < ActiveSupport::TestCase end end + def test_dependency_which_raises_doesnt_blindly_call_blame_file! + with_loading do + filename = 'dependencies/raises_exception_without_blame_file' + + assert_raises(Exception) { require_dependency filename } + end + end + def test_warnings_should_be_enabled_on_first_load with_loading 'dependencies' do old_warnings, ActiveSupport::Dependencies.warnings_on_first_load = ActiveSupport::Dependencies.warnings_on_first_load, true |