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

Ticket #5408: traversal_unit_test.diff

File traversal_unit_test.diff, 0.8 kB (added by nkriege@hotmail.com, 2 years ago)

Slightly convoluted, but hopefully this unit test gets the point across

  • actionpack/test/controller/routing_test.rb

    old new  
    972972  end 
    973973end 
    974974 
     975class TraversalTests < Test::Unit::TestCase 
     976  class Request 
     977    attr_accessor :path, :path_parameters 
     978     
     979    def initialize(path) 
     980      @path = path 
     981      @path_parmeters = {} 
     982    end 
     983  end 
     984 
     985  def test_invalid_module 
     986    assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" 
     987 
     988    request = Request.new("/profile") 
     989    begin 
     990      ActionController::Routing::Routes.recognize!(request) 
     991    rescue ActionController::RoutingError 
     992    end 
     993     
     994    assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" 
     995  end 
    975996end 
     997 
     998end