aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2018-03-25 11:02:25 +0100
committerAndrew White <andrew.white@unboxed.co>2018-03-25 11:07:26 +0100
commit9232ba71190eb4e29964d60bd7ba6d7bb6118a43 (patch)
treeaca89dbcd3dda24d650a5e6b17044a7ba9014fc5 /actionpack/lib/action_dispatch
parent8881d84369f5eaf78009a18859e9ef751aedf53c (diff)
downloadrails-9232ba71190eb4e29964d60bd7ba6d7bb6118a43.tar.gz
rails-9232ba71190eb4e29964d60bd7ba6d7bb6118a43.tar.bz2
rails-9232ba71190eb4e29964d60bd7ba6d7bb6118a43.zip
Make engine check more explicit
Not everything that responds to `routes` is a Rails engine - for example a Grape API endpoint will have a `routes` method but can't be used with `assert_recognizes` as it doesn't respond to `recognize_path_with_request`. Fixes #32312.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/endpoint.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/endpoint.rb b/actionpack/lib/action_dispatch/routing/endpoint.rb
index 24dced1efd..28bb20d688 100644
--- a/actionpack/lib/action_dispatch/routing/endpoint.rb
+++ b/actionpack/lib/action_dispatch/routing/endpoint.rb
@@ -3,12 +3,15 @@
module ActionDispatch
module Routing
class Endpoint # :nodoc:
- def dispatcher?; false; end
- def redirect?; false; end
- def engine?; rack_app.respond_to?(:routes); end
- def matches?(req); true; end
- def app; self; end
- def rack_app; app; end
+ def dispatcher?; false; end
+ def redirect?; false; end
+ def matches?(req); true; end
+ def app; self; end
+ def rack_app; app; end
+
+ def engine?
+ rack_app.is_a?(Class) && rack_app < Rails::Engine
+ end
end
end
end