Permalink
Browse files

Merge pull request #13669 from chulkilee/name-error-name

Set NameError#name
  • Loading branch information...
2 parents 5873036 + bea44cb commit f6ca00bd43a497ef46aa630469e95eda4e43f018 @senny senny committed Jan 14, 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 f6ca00b

Please sign in to comment.