public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fix Dependencies watch_frames collection. [#24 state:resolved]

Previously, the code collecting watch_frames could fail leaving
watch_frames defined but nil. The cleanup code checks watch_frames
is defined, but not that it holds a value, raising an undefined method
on NilClass error rather than the original cause.  This can make
debugging the underlying cause a total pain.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
tomafro (author)
Tue Apr 29 05:21:51 -0700 2008
lifo (committer)
Tue May 20 03:44:23 -0700 2008
commit  ebb642fa3a2b1a4e31abf9610ca634e6bb5d57d3
tree    d62b969fa48509a4bd8f228950ad9ce4627be518
parent  089251581137b041828a7e6dcbf75ecbef55b4a3
...
384
385
386
387
 
388
389
390
...
384
385
386
 
387
388
389
390
0
@@ -384,7 +384,7 @@ module Dependencies #:nodoc:
0
     return new_constants
0
   ensure
0
     # Remove the stack frames that we added.
0
-    if defined?(watch_frames) && ! watch_frames.empty?
0
+    if defined?(watch_frames) && ! watch_frames.blank?
0
       frame_ids = watch_frames.collect(&:object_id)
0
       constant_watch_stack.delete_if do |watch_frame|
0
         frame_ids.include? watch_frame.object_id
...
584
585
586
 
 
 
 
 
 
587
588
589
...
584
585
586
587
588
589
590
591
592
593
594
595
0
@@ -584,6 +584,12 @@ class DependenciesTest < Test::Unit::TestCase
0
     assert_equal [], m
0
   end
0
 
0
+  def test_new_constants_in_with_illegal_module_name_raises_correct_error
0
+    assert_raises(NameError) do
0
+      Dependencies.new_constants_in("Illegal-Name") {}
0
+    end
0
+  end
0
+
0
   def test_file_with_multiple_constants_and_require_dependency
0
     with_loading 'autoloading_fixtures' do
0
       assert ! defined?(MultipleConstantFile)

Comments