From 9fd0c605b9bcfb2c2e854f3120bd3625eaa017f5 Mon Sep 17 00:00:00 2001 From: Xavier Defrang Date: Fri, 28 Jun 2013 15:37:26 +0200 Subject: Verify that route constraints respond to the expected messages instead of silently failing to enforce the constraint --- actionpack/test/dispatch/routing_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 8e4339aa0c..e1ce3648e8 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -3593,6 +3593,21 @@ class TestFormatConstraints < ActionDispatch::IntegrationTest end end +class TestCallableConstraintValidation < ActionDispatch::IntegrationTest + + def test_constraint_with_object_not_callable + assert_raise(ArgumentError) do + ActionDispatch::Routing::RouteSet.new.tap do |app| + app.draw do + ok = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, []] } + get '/test', to: ok, constraints: Object.new + end + end + end + end + +end + class TestRouteDefaults < ActionDispatch::IntegrationTest stub_controllers do |routes| Routes = routes -- cgit v1.2.3