aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormisfo <tedwardo2@gmail.com>2009-03-14 10:42:02 -0500
committerJoshua Peek <josh@joshpeek.com>2009-03-14 10:42:02 -0500
commit7706b57034e91820cf83445aede57c54ab66ac2d (patch)
tree34f8e267eecabd996ab1acd66f709a00aa1ea8c7
parent112056333f6ad2492a37b7eb9d647ecd23980592 (diff)
downloadrails-7706b57034e91820cf83445aede57c54ab66ac2d.tar.gz
rails-7706b57034e91820cf83445aede57c54ab66ac2d.tar.bz2
rails-7706b57034e91820cf83445aede57c54ab66ac2d.zip
allowed render :file to take Pathnames [#2220 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
-rw-r--r--actionpack/lib/action_view/template.rb2
-rw-r--r--actionpack/test/controller/render_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 0dd3a7e619..c339c8a554 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -218,7 +218,7 @@ module ActionView #:nodoc:
# 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]
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index af623395f0..a52931565d 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -157,6 +157,11 @@ class TestController < ActionController::Base
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 @@ class RenderTest < ActionController::TestCase
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