diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-05-06 12:44:03 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-05-06 12:47:32 -0700 |
commit | a29bc1cf7b8580a815523e4c3a79e931f03ab8c2 (patch) | |
tree | 306a94759830a7cf313faef09874e6dd0830a365 /actionpack/test | |
parent | 9d03e20b1969c267a524873907f6993e351cfc97 (diff) | |
download | rails-a29bc1cf7b8580a815523e4c3a79e931f03ab8c2.tar.gz rails-a29bc1cf7b8580a815523e4c3a79e931f03ab8c2.tar.bz2 rails-a29bc1cf7b8580a815523e4c3a79e931f03ab8c2.zip |
Fix that optimized named routes should also work as singleton methods on the url_helpers module
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index c8e1b34b99..e5345754cd 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2538,3 +2538,27 @@ class TestConstraintsAccessingParameters < ActionDispatch::IntegrationTest assert_equal "bar", @request.params[:bar] end end + +class TestOptimizedNamedRoutes < ActionDispatch::IntegrationTest + Routes = ActionDispatch::Routing::RouteSet.new.tap do |app| + app.draw do + ok = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, []] } + get '/foo' => ok, as: :foo + end + end + + include Routes.url_helpers + def app; Routes end + + test 'enabled when not mounted and default_url_options is empty' do + assert Routes.url_helpers.optimize_routes_generation? + end + + test 'named route called as singleton method' do + assert_equal '/foo', Routes.url_helpers.foo_path + end + + test 'named route called on included module' do + assert_equal '/foo', foo_path + end +end |