Browse files

fix regression in Mapper when `format:` was used in a `scope`.

Closes #10071

`#normalize_path!` depends on the options so we need to call
`#normalize_options!` first to make sure everything is set correctly.
  • Loading branch information...
1 parent 3768326 commit 33971922b3af559d6583b472d1520bc4d13daccc @senny senny committed Apr 3, 2013
Showing with 23 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +22 −0 actionpack/test/dispatch/routing_test.rb
View
2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -58,8 +58,8 @@ def initialize(set, scope, path, options)
@set, @scope, @path, @options = set, scope, path, options
@requirements, @conditions, @defaults = {}, {}, {}
- normalize_path!
normalize_options!
+ normalize_path!
normalize_requirements!
normalize_conditions!
normalize_defaults!
View
22 actionpack/test/dispatch/routing_test.rb
@@ -1102,6 +1102,28 @@ def test_scoped_root
assert_equal 'projects#index', @response.body
end
+ def test_scope_with_format_option
+ draw do
+ get "direct/index", as: :no_format_direct, format: false
+
+ scope format: false do
+ get "scoped/index", as: :no_format_scoped
+ end
+ end
+
+ assert_equal "/direct/index", no_format_direct_path
+ assert_equal "/direct/index?format=html", no_format_direct_path(format: "html")
+
+ assert_equal "/scoped/index", no_format_scoped_path
+ assert_equal "/scoped/index?format=html", no_format_scoped_path(format: "html")
+
+ get '/scoped/index'
+ assert_equal "scoped#index", @response.body
+
+ get '/scoped/index.html'
+ assert_equal "Not Found", @response.body
+ end
+
def test_index
draw do
get '/info' => 'projects#info', :as => 'info'

0 comments on commit 3397192

Please sign in to comment.