mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
allowed render :file to take Pathnames [#2220 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
112056333f
commit
7706b57034
2 changed files with 11 additions and 1 deletions
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue