Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

push rails app testing up

this way we only have to test for whether it is a rails app once.
  • Loading branch information...
commit 9b15828b5c347395b42066a588c88e5eb4e72279 1 parent 4a7b959
@tenderlove tenderlove authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 actionpack/lib/action_dispatch/routing/mapper.rb
View
22 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -577,13 +577,21 @@ def mount(app, options = nil)
raise "A rack application must be specified" unless path
- options[:as] ||= app_name(app)
+ rails_app = rails_app? app
+
+ if rails_app
+ options[:as] ||= app.railtie_name
+ else
+ # non rails apps can't have an :as
@byroot
byroot added a note

They used to be able to, and the doc still state they can:

capture d ecran 2014-11-28 a 14 55 12

Was that change intentional?

@chancancode Owner
@byroot
byroot added a note

@chancancode the discussion moved here: #17823 @rafaelfranca confirned this is a regression. I'm just trying to come with a unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ options[:as] = nil
+ end
+
target_as = name_for_action(options[:as], path)
options[:via] ||= :all
match(path, options.merge(:to => app, :anchor => false, :format => false))
- define_generate_prefix(app, target_as)
+ define_generate_prefix(app, target_as) if rails_app
self
end
@@ -604,15 +612,11 @@ def has_named_route?(name)
end
private
- def app_name(app)
- return unless app.is_a?(Class) && app < Rails::Railtie
-
- app.railtie_name
+ def rails_app?(app)
+ app.is_a?(Class) && app < Rails::Railtie
end
def define_generate_prefix(app, name)
- return unless app.is_a?(Class) && app < Rails::Railtie
-
_route = @set.named_routes.routes[name.to_sym]
_routes = @set
app.routes.define_mounted_helper(name)
@@ -1541,7 +1545,7 @@ def add_route(action, options) # :nodoc:
action = nil
end
- if !options.fetch(:as, true)
+ if !options.fetch(:as, true) # if it's set to nil or false
options.delete(:as)
else
options[:as] = name_for_action(options[:as], action)
Please sign in to comment.
Something went wrong with that request. Please try again.