mirror of
https://github.com/github/rails.git
synced 2026-01-29 00:08:15 -05:00
Correct line numbers from template errors. Closes #10937 [Aleksey Kondratenko]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8744 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -25,7 +25,7 @@ module ActionView
|
||||
|
||||
begin
|
||||
file_name = 'compiled-template' if file_name.blank?
|
||||
ActionView::Base::CompiledTemplates.module_eval(render_source, file_name, line_offset)
|
||||
ActionView::Base::CompiledTemplates.module_eval(render_source, file_name, -line_offset)
|
||||
rescue Exception => e # errors from template code
|
||||
if @view.logger
|
||||
@view.logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
|
||||
|
||||
@@ -86,6 +86,15 @@ class TestController < ActionController::Base
|
||||
render :xml => "<blah/>", :content_type => "application/atomsvc+xml"
|
||||
end
|
||||
|
||||
def render_line_offset
|
||||
begin
|
||||
render :inline => '<% raise %>', :locals => {:foo => 'bar'}
|
||||
rescue => exc
|
||||
end
|
||||
line = exc.backtrace.first
|
||||
render :text => line
|
||||
end
|
||||
|
||||
def heading
|
||||
head :ok
|
||||
end
|
||||
@@ -225,6 +234,13 @@ class RenderTest < Test::Unit::TestCase
|
||||
assert_template "test/hello_world"
|
||||
end
|
||||
|
||||
def test_line_offset
|
||||
get :render_line_offset
|
||||
line = @response.body
|
||||
assert(line =~ %r{:(\d+):})
|
||||
assert_equal "1", $1
|
||||
end
|
||||
|
||||
def test_render_with_forward_slash
|
||||
get :render_hello_world_with_forward_slash
|
||||
assert_template "test/hello_world"
|
||||
|
||||
Reference in New Issue
Block a user