push option decomposition up a bit more

I think we can find the original place where `action` is added to the
options hash now.
This commit is contained in:
Aaron Patterson 2015-08-11 13:54:25 -07:00
parent 934bdf6724
commit 5935e4c882
2 changed files with 6 additions and 6 deletions

@ -61,7 +61,7 @@ class Mapping #:nodoc:
attr_reader :requirements, :conditions, :defaults
attr_reader :to, :default_controller, :default_action, :as, :anchor
def self.build(scope, set, path, as, controller, options)
def self.build(scope, set, path, as, controller, default_action, options)
options = scope[:options].merge(options) if scope[:options]
options.delete :only
@ -72,8 +72,6 @@ def self.build(scope, set, path, as, controller, options)
defaults = (scope[:defaults] || {}).dup
default_action = options.delete(:action) || scope[:action]
new scope, set, path, defaults, as, controller, default_action, options
end
@ -1593,7 +1591,9 @@ def add_route(action, controller, options) # :nodoc:
name_for_action(options.delete(:as), action)
end
mapping = Mapping.build(@scope, @set, URI.parser.escape(path), as, controller, options)
default_action = options.delete(:action) || @scope[:action]
mapping = Mapping.build(@scope, @set, URI.parser.escape(path), as, controller, default_action, options)
app, conditions, requirements, defaults, as, anchor = mapping.to_route
@set.add_route(app, conditions, requirements, defaults, as, anchor)
end

@ -41,8 +41,8 @@ def test_initialize
end
def test_mapping_requirements
options = { :action => 'bar', :via => :get }
m = Mapper::Mapping.build({}, FakeSet.new, '/store/:name(*rest)', nil, 'foo', options)
options = { :via => :get }
m = Mapper::Mapping.build({}, FakeSet.new, '/store/:name(*rest)', nil, 'foo', 'bar', options)
_, _, requirements, _ = m.to_route
assert_equal(/.+?/, requirements[:rest])
end