1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #10795 from atambo/master

Don't blindly call blame_file! on exceptions in ActiveSupport::Dependes::Loadable
This commit is contained in:
Steve Klabnik 2013-06-09 23:48:28 -07:00
commit cbfcd9ddf1
4 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,8 @@
* Fix `ActiveSupport::Dependencies::Loadable#load_dependency` calling
`#blame_file!` on Exceptions that do not have the Blamable mixin
*Andrew Kreiling*
* Override `Time.at` to support the passing of Time-like values when called with a single argument.
*Andrew White*

View file

@ -213,7 +213,7 @@ module ActiveSupport #:nodoc:
yield
end
rescue Exception => exception # errors from loading file
exception.blame_file! file
exception.blame_file! file if exception.respond_to? :blame_file!
raise
end

View file

@ -0,0 +1,5 @@
exception = Exception.new('I am not blamable!')
class << exception
undef_method(:blame_file!)
end
raise exception

View file

@ -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