diff options
author | Matthew Draper <matthew@trebex.net> | 2014-07-18 23:42:31 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-07-18 23:42:31 +0930 |
commit | 843b8c0b8c8cccd8d1432060dfc79a8edcc4ed2c (patch) | |
tree | c3b8ec1d8a1ee6d401246af4ec10e4a97ebd6851 /activerecord/test | |
parent | ba9fe6cf90c12e3f81861e795b1c7299c3315b74 (diff) | |
parent | c965de396f1bd7457159306f1fc10342840fdf86 (diff) | |
download | rails-843b8c0b8c8cccd8d1432060dfc79a8edcc4ed2c.tar.gz rails-843b8c0b8c8cccd8d1432060dfc79a8edcc4ed2c.tar.bz2 rails-843b8c0b8c8cccd8d1432060dfc79a8edcc4ed2c.zip |
Merge pull request #15762 from arthurnn/better_error_on_bad_alias_method
Dont swallow errors when bad alias_method
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 8f83cf7cb4..4c0b0c868a 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1347,14 +1347,32 @@ class BasicsTest < ActiveRecord::TestCase end def test_compute_type_no_method_error - ActiveSupport::Dependencies.stubs(:constantize).raises(NoMethodError) + ActiveSupport::Dependencies.stubs(:safe_constantize).raises(NoMethodError) assert_raises NoMethodError do ActiveRecord::Base.send :compute_type, 'InvalidModel' end end + def test_compute_type_on_undefined_method + error = nil + begin + Class.new(Author) do + alias_method :foo, :bar + end + rescue => e + error = e + end + + ActiveSupport::Dependencies.stubs(:safe_constantize).raises(e) + + exception = assert_raises NameError do + ActiveRecord::Base.send :compute_type, 'InvalidModel' + end + assert_equal error.message, exception.message + end + def test_compute_type_argument_error - ActiveSupport::Dependencies.stubs(:constantize).raises(ArgumentError) + ActiveSupport::Dependencies.stubs(:safe_constantize).raises(ArgumentError) assert_raises ArgumentError do ActiveRecord::Base.send :compute_type, 'InvalidModel' end |