aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorChulki Lee <chulki.lee@gmail.com>2014-01-10 16:27:18 -0800
committerChulki Lee <chulki.lee@gmail.com>2014-01-13 12:47:14 -0800
commitbea44cbaa48433d427a9418ff6b5c617b10e0585 (patch)
tree89bc319a4b5396c57da214411ec06f69f0e231fe /activerecord
parent8b70319c270415e9f99ed8eb1f12dd1caaade1fd (diff)
downloadrails-bea44cbaa48433d427a9418ff6b5c617b10e0585.tar.gz
rails-bea44cbaa48433d427a9418ff6b5c617b10e0585.tar.bz2
rails-bea44cbaa48433d427a9418ff6b5c617b10e0585.zip
Set NameError#name
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md4
-rw-r--r--activerecord/lib/active_record/inheritance.rb2
-rw-r--r--activerecord/test/cases/base_test.rb4
3 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index f57158f38e..7db700a27a 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Set NameError#name with class name when failed to load the class for association.
+
+ *Chulki Lee*
+
* Fix bug in `becomes!` when changing from the base model to a STI sub-class.
Fixes #13272.
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index 949e7678a5..69896f7219 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -126,7 +126,7 @@ module ActiveRecord
end
end
- raise NameError, "uninitialized constant #{candidates.first}"
+ raise NameError.new("uninitialized constant #{candidates.first}", candidates.first)
end
end
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index cb8e564da1..4bc6002bfe 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1301,9 +1301,11 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_compute_type_nonexistent_constant
- assert_raises NameError do
+ e = assert_raises NameError do
ActiveRecord::Base.send :compute_type, 'NonexistentModel'
end
+ assert_equal 'uninitialized constant ActiveRecord::Base::NonexistentModel', e.message
+ assert_equal 'ActiveRecord::Base::NonexistentModel', e.name
end
def test_compute_type_no_method_error