Skip to content
Browse files

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

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent 1120563 commit 7706b57034e91820cf83445aede57c54ab66ac2d @misfo misfo committed with josh
Showing with 11 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_view/template.rb
  2. +10 −0 actionpack/test/controller/render_test.rb
View
2 actionpack/lib/action_view/template.rb
@@ -218,7 +218,7 @@ def valid_locale?(locale)
# Returns file split into an array
# [base_path, name, locale, format, extension]
def split(file)
- if m = file.match(/^(.*\/)?([^\.]+)\.(.*)$/)
+ if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/)
base_path = m[1]
name = m[2]
extensions = m[3]
View
10 actionpack/test/controller/render_test.rb
@@ -157,6 +157,11 @@ def render_file_not_using_full_path_with_dot_in_path
render :file => 'test/dot.directory/render_file_with_ivar'
end
+ def render_file_using_pathname
+ @secret = 'in the sauce'
+ render :file => Pathname.new(File.dirname(__FILE__)).join('..', 'fixtures', 'test', 'dot.directory', 'render_file_with_ivar.erb')
+ end
+
def render_file_from_template
@secret = 'in the sauce'
@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
assert_equal "The secret is in the sauce\n", @response.body
end
+ def test_render_file_using_pathname
+ get :render_file_using_pathname
+ assert_equal "The secret is in the sauce\n", @response.body
+ end
+
def test_render_file_with_locals
get :render_file_with_locals
assert_equal "The secret is in the sauce\n", @response.body

1 comment on commit 7706b57

@ncr

rcov 1000% ;)

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