Skip to content

Commit 7706b57

Browse files
misfojosh
authored andcommitted
allowed render :file to take Pathnames [rails#2220 state:resolved]
Signed-off-by: Joshua Peek <[email protected]>
1 parent 1120563 commit 7706b57

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

actionpack/lib/action_view/template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def valid_locale?(locale)
218218
# Returns file split into an array
219219
# [base_path, name, locale, format, extension]
220220
def split(file)
221-
if m = file.match(/^(.*\/)?([^\.]+)\.(.*)$/)
221+
if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/)
222222
base_path = m[1]
223223
name = m[2]
224224
extensions = m[3]

actionpack/test/controller/render_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ def render_file_not_using_full_path_with_dot_in_path
157157
render :file => 'test/dot.directory/render_file_with_ivar'
158158
end
159159

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+
160165
def render_file_from_template
161166
@secret = 'in the sauce'
162167
@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
861866
assert_equal "The secret is in the sauce\n", @response.body
862867
end
863868

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+
864874
def test_render_file_with_locals
865875
get :render_file_with_locals
866876
assert_equal "The secret is in the sauce\n", @response.body

0 commit comments

Comments
 (0)