Permalink
Browse files

Set NameError#name

  • Loading branch information...
1 parent 8b70319 commit bea44cbaa48433d427a9418ff6b5c617b10e0585 @chulkilee chulkilee committed Jan 11, 2014
@@ -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.
@@ -126,7 +126,7 @@ def compute_type(type_name)
end
end
- raise NameError, "uninitialized constant #{candidates.first}"
+ raise NameError.new("uninitialized constant #{candidates.first}", candidates.first)
end
end
@@ -1301,9 +1301,11 @@ def test_compute_type_success
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

0 comments on commit bea44cb

Please sign in to comment.