Skip to content
This repository
Browse code

allowed render :file to take Pathnames [#2220 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit 7706b57034e91820cf83445aede57c54ab66ac2d 1 parent 1120563
Trent Ogren authored March 14, 2009 josh committed March 14, 2009
2  actionpack/lib/action_view/template.rb
@@ -218,7 +218,7 @@ def valid_locale?(locale)
218 218
       # Returns file split into an array
219 219
       #   [base_path, name, locale, format, extension]
220 220
       def split(file)
221  
-        if m = file.match(/^(.*\/)?([^\.]+)\.(.*)$/)
  221
+        if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/)
222 222
           base_path = m[1]
223 223
           name = m[2]
224 224
           extensions = m[3]
10  actionpack/test/controller/render_test.rb
@@ -157,6 +157,11 @@ def render_file_not_using_full_path_with_dot_in_path
157 157
     render :file => 'test/dot.directory/render_file_with_ivar'
158 158
   end
159 159
 
  160
+  def render_file_using_pathname
  161
+    @secret = 'in the sauce'
  162
+    render :file => Pathname.new(File.dirname(__FILE__)).join('..', 'fixtures', 'test', 'dot.directory', 'render_file_with_ivar.erb')
  163
+  end
  164
+
160 165
   def render_file_from_template
161 166
     @secret = 'in the sauce'
162 167
     @path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb'))
@@ -861,6 +866,11 @@ def test_render_file_not_using_full_path_with_dot_in_path
861 866
     assert_equal "The secret is in the sauce\n", @response.body
862 867
   end
863 868
 
  869
+  def test_render_file_using_pathname
  870
+    get :render_file_using_pathname
  871
+    assert_equal "The secret is in the sauce\n", @response.body
  872
+  end
  873
+
864 874
   def test_render_file_with_locals
865 875
     get :render_file_with_locals
866 876
     assert_equal "The secret is in the sauce\n", @response.body

1 note on commit 7706b57

Jacek Becela
ncr commented on 7706b57 March 14, 2009

rcov 1000% ;)

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