From 5935e4c882b89d539d7a1441263bc265d397cf8e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 11 Aug 2015 13:54:25 -0700 Subject: push option decomposition up a bit more I think we can find the original place where `action` is added to the options hash now. --- actionpack/lib/action_dispatch/routing/mapper.rb | 8 ++++---- actionpack/test/dispatch/mapper_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 92e32ac29b..a207349e11 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -61,7 +61,7 @@ module ActionDispatch 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 @@ module ActionDispatch 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 @@ module ActionDispatch 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 diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index 18daa62425..0a7550eb4a 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -41,8 +41,8 @@ module ActionDispatch 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 -- cgit v1.2.3