aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb9
-rw-r--r--actionpack/test/controller/resources_test.rb2
2 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index f52fb91e97..d53c10e5f3 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -898,6 +898,15 @@ module ActionDispatch
return self
end
+ via = Array.wrap(options[:via]).map(&:to_sym)
+ if via.include?(:head)
+ raise ArgumentError, "HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers"
+ end
+
+ unless (invalid = via - HTTP_METHODS).empty?
+ raise ArgumentError, "Invalid HTTP method (#{invalid.join(', ')}) specified in :via"
+ end
+
on = options.delete(:on)
if VALID_ON_OPTIONS.include?(on)
args.push(options)
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 3dc2429dae..0573eac119 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -718,7 +718,7 @@ class ResourcesTest < ActionController::TestCase
set.draw do
resources :messages do
member do
- match :something, :via => :invalid
+ match :something, :via => [:invalid, :get]
end
end
end