Skip to content

Commit

Permalink
Added testing of named routes #1506 [Nicholas Seckar]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1517 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jun 26, 2005
1 parent 1bb676b commit ee4c834
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions actionpack/lib/action_controller/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ module Unit #:nodoc:
#
# For redirects within the same controller, you can even call follow_redirect and the redirect will be follow triggering another
# action call which can then be asserted against.
#
# == Testing named routes
#
# If you're using named routes, they can be easily tested using the original named routes methods straight in the test case.
# Example:
#
# assert_redirected_to page_url(:title => 'foo')
module Assertions
# Asserts that the response is one of the following types:
#
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def name_route(route, name)

protected url_helper_name(name), hash_access_name(name)

Helpers << url_helper_name(name)
Helpers << url_helper_name(name).to_sym
Helpers.uniq!
end

Expand Down
7 changes: 6 additions & 1 deletion actionpack/lib/action_controller/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ def require_html_scanner
$:.unshift File.dirname(__FILE__) + "/vendor/html-scanner"
require 'html/document'
end
end

def method_missing(selector, *args)
return @controller.send(selector, *args) if ActionController::Routing::NamedRoutes::Helpers.include?(selector)
return super
end
end
end
end

0 comments on commit ee4c834

Please sign in to comment.