mirror of https://github.com/rails/rails
Merge pull request #51933 from zzak/51910
Handle case where script_name is a blank string
This commit is contained in:
commit
bc56661a3d
|
@ -714,7 +714,7 @@ module ActionDispatch
|
||||||
def optimize_routes_generation?; false; end
|
def optimize_routes_generation?; false; end
|
||||||
|
|
||||||
define_method :find_script_name do |options|
|
define_method :find_script_name do |options|
|
||||||
if options.key? :script_name
|
if options.key?(:script_name) && options[:script_name].present?
|
||||||
super(options)
|
super(options)
|
||||||
else
|
else
|
||||||
script_namer.call(options)
|
script_namer.call(options)
|
||||||
|
|
|
@ -1070,6 +1070,73 @@ en:
|
||||||
assert_equal "ok", last_response.body
|
assert_equal "ok", last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "nested isolated engines should set correct route module prefix" do
|
||||||
|
app = File.readlines("#{app_path}/config/application.rb")
|
||||||
|
app.insert(6, "require \"bukkits/awesome\"")
|
||||||
|
File.open("#{app_path}/config/application.rb", "r+") do |f|
|
||||||
|
f.puts app
|
||||||
|
end
|
||||||
|
|
||||||
|
@plugin.write "lib/bukkits.rb", <<-RUBY
|
||||||
|
module Bukkits
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
isolate_namespace Bukkits
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
@plugin.write "lib/bukkits/awesome.rb", <<-RUBY
|
||||||
|
module Bukkits
|
||||||
|
module Awesome
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
isolate_namespace Bukkits::Awesome
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
app_file "config/routes.rb", <<-RUBY
|
||||||
|
Rails.application.routes.draw do
|
||||||
|
mount Bukkits::Engine, at: "/bukkits"
|
||||||
|
end
|
||||||
|
|
||||||
|
Bukkits::Engine.routes.draw do
|
||||||
|
get "/foo" => "foo#index"
|
||||||
|
|
||||||
|
mount Bukkits::Awesome::Engine, at: "/awesome"
|
||||||
|
end
|
||||||
|
|
||||||
|
Bukkits::Awesome::Engine.routes.draw do
|
||||||
|
get "/bar", as: :bar, to: "bar#index"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
@plugin.write "app/controllers/bukkits/foo_controller.rb", <<-RUBY
|
||||||
|
class Bukkits::FooController < ActionController::Base
|
||||||
|
def index
|
||||||
|
render plain: bukkits_awesome.bar_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
@plugin.write "app/controllers/bukkits/awesome/bar_controller.rb", <<-RUBY
|
||||||
|
class Bukkits::Awesome::BarController < ActionController::Base
|
||||||
|
def index
|
||||||
|
render plain: "ok"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
add_to_config("config.action_dispatch.show_exceptions = :none")
|
||||||
|
|
||||||
|
boot_rails
|
||||||
|
|
||||||
|
get("/bukkits/foo")
|
||||||
|
assert_equal "/bukkits/awesome/bar", last_response.body
|
||||||
|
get("/bukkits/awesome/bar")
|
||||||
|
assert_equal "ok", last_response.body
|
||||||
|
end
|
||||||
|
|
||||||
test "loading seed data" do
|
test "loading seed data" do
|
||||||
@plugin.write "db/seeds.rb", <<-RUBY
|
@plugin.write "db/seeds.rb", <<-RUBY
|
||||||
Bukkits::Engine.config.bukkits_seeds_loaded = true
|
Bukkits::Engine.config.bukkits_seeds_loaded = true
|
||||||
|
|
Loading…
Reference in New Issue