Skip to content
This repository
Browse code

Fixed that ActionView#file_exists? would be incorrect if @first_rende…

…r is set (closes #10569) [dbussink]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8385 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 78727dd8e226f16fd2446db0bcaf41e127ba9bc8 1 parent 7a22435
David Heinemeier Hansson authored December 14, 2007
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Fixed that ActionView#file_exists? would be incorrect if @first_render is set #10569 [dbussink]
  4
+
3 5
 * Added that Array#to_param calls to_param on all it's elements #10473 [brandon]
4 6
 
5 7
 * Ensure asset cache directories are automatically created.  #10337 [Josh Peek, Chu Yeow]
2  actionpack/lib/action_view/base.rb
@@ -404,7 +404,7 @@ def file_exists?(template_path)#:nodoc:
404 404
       if template_file_extension
405 405
         template_exists?(template_file_name, template_file_extension)
406 406
       else
407  
-        pick_template_extension(template_path)
  407
+        template_exists?(template_file_name, pick_template_extension(template_path))
408 408
       end
409 409
     end
410 410
 
18  actionpack/test/action_view_test.rb
@@ -23,4 +23,22 @@ def test_find_template_extension_from_first_render
23 23
       assert_equal expectation, base.send(:find_template_extension_from_first_render)
24 24
     end
25 25
   end
  26
+  
  27
+  def test_should_report_file_exists_correctly
  28
+    base = ActionView::Base.new
  29
+
  30
+    assert_nil base.send(:find_template_extension_from_first_render)
  31
+    
  32
+    assert_equal false, base.send(:file_exists?, 'test.rhtml')
  33
+    assert_equal false, base.send(:file_exists?, 'test.rb')
  34
+
  35
+    base.instance_variable_set('@first_render', 'foo.rb')
  36
+    
  37
+    assert_equal 'rb', base.send(:find_template_extension_from_first_render)
  38
+    
  39
+    assert_equal false, base.send(:file_exists?, 'baz')
  40
+    assert_equal false, base.send(:file_exists?, 'baz.rb')
  41
+
  42
+  end
  43
+  
26 44
 end

0 notes on commit 78727dd

Please sign in to comment.
Something went wrong with that request. Please try again.