Skip to content

Commit

Permalink
allowed render :file to take Pathnames [#2220 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
misfo authored and josh committed Mar 14, 2009
1 parent 1120563 commit 7706b57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template.rb
Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -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'))
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 7706b57

@ncr
Copy link
Contributor

@ncr ncr commented on 7706b57 Mar 14, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rcov 1000% ;)

Please sign in to comment.