Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4158

Show
Ignore:
Timestamp:
04/04/06 19:37:29 (2 years ago)
Author:
ulysses
Message:

Update the diagnostics template skip the useless '<controller not set>' text.
Fix symbol extensions test case.
Clean paths inside of exception messages and traces.
Add Pathname.clean_within for cleaning all the paths inside of a string.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4157 r4158  
    11*SVN* 
     2 
     3* Update the diagnostics template skip the useless '<controller not set>' text. [Nicholas Seckar] 
    24 
    35* CHANGED DEFAULT: Don't parse YAML input by default, but keep it available as an easy option [DHH] 
  • trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml

    r2624 r4158  
    11<h1> 
    2   <%=h @exception.class.to_s %> in 
    3   <%=h (@request.parameters["controller"] || "<controller not set>").capitalize %>#<%=h @request.parameters["action"] || "<action not set>" %> 
     2  <%=h @exception.class.to_s %> 
     3  <% if @request.parameters['controller'] %> 
     4    in <%=h @request.parameters['controller'].humanize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %> 
     5  <% end %> 
    46</h1> 
    57<pre><%=h @exception.clean_message %></pre> 
  • trunk/activesupport/CHANGELOG

    r4136 r4158  
    11* SVN * 
     2 
     3* Clean paths inside of exception messages and traces. [Nicholas Seckar] 
     4 
     5* Add Pathname.clean_within for cleaning all the paths inside of a string. [Nicholas Seckar] 
    26 
    37* provide an empty Dependencies::LoadingModule.load which prints deprecation warnings.  Lets 1.0 applications function with .13-style environment.rb. 
  • trunk/activesupport/lib/active_support/core_ext/exception.rb

    r3493 r4158  
    1 class Exception 
    2   alias :clean_message :message 
     1class Exception # :nodoc: 
     2  def clean_message 
     3    Pathname.clean_within message 
     4  end 
    35   
    46  TraceSubstitutions = [] 
    5   FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/ 
     7  FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/ 
    68   
    79  def clean_backtrace 
    810    backtrace.collect do |line| 
    9       TraceSubstitutions.inject(line) do |line, (regexp, sub)| 
     11      Pathname.clean_within(TraceSubstitutions.inject(line) do |line, (regexp, sub)| 
    1012        line.gsub regexp, sub 
    11       end 
     13      end) 
    1214    end 
    1315  end 
     
    1618    before_application_frame = true 
    1719     
    18     clean_backtrace.reject do |line| 
    19       non_app_frame = !! (line =~ FrameworkRegexp) 
     20    trace = clean_backtrace.reject do |line| 
     21      non_app_frame = (line =~ FrameworkRegexp) 
    2022      before_application_frame = false unless non_app_frame 
    2123      non_app_frame && ! before_application_frame 
    2224    end 
     25     
     26    # If we didn't find any application frames, return an empty app trace. 
     27    before_application_frame ? [] : trace 
    2328  end 
    2429   
  • trunk/activesupport/test/core_ext/exception_test.rb

    r2676 r4158  
    4242    assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace 
    4343  end 
    44  
    4544   
     45  def test_backtrace_should_clean_paths 
     46    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     47    e = get_exception RuntimeError, 'RAWR', ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] 
     48    assert_kind_of Exception, e 
     49    assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 
     50  end 
     51   
     52  def test_clean_message_should_clean_paths 
     53    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     54    e = get_exception RuntimeError, "I dislike a/z/x/../../b/y/../c", ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] 
     55    assert_kind_of Exception, e 
     56    assert_equal "I dislike a/b/c", e.clean_message 
     57  end 
     58   
     59  def test_app_trace_should_be_empty_when_no_app_frames 
     60    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     61    e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'generated/bhal.rb', ' vendor/file.rb some stuff', 'generated/almost all'] 
     62    assert_kind_of Exception, e 
     63    assert_equal [], e.application_backtrace 
     64  end 
    4665end 
  • trunk/activesupport/test/core_ext/symbol_test.rb

    r3118 r4158  
    22require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' 
    33 
    4 class TestSymbol < Test::Case::TestUnit 
     4class SymbolTests < Test::Unit::TestCase 
    55  def test_to_proc 
    6     assert_equal %w(one two three), [:one, :two, :three].map &:to_s 
     6    assert_equal %w(one two three), [:one, :two, :three].map(&:to_s) 
    77  end 
    88end