@@ -1070,6 +1070,73 @@ def index
1070
1070
assert_equal "ok" , last_response . body
1071
1071
end
1072
1072
1073
+ test "nested isolated engines should set correct route module prefix" do
1074
+ app = File . readlines ( "#{ app_path } /config/application.rb" )
1075
+ app . insert ( 6 , "require \" bukkits/awesome\" " )
1076
+ File . open ( "#{ app_path } /config/application.rb" , "r+" ) do |f |
1077
+ f . puts app
1078
+ end
1079
+
1080
+ @plugin . write "lib/bukkits.rb" , <<-RUBY
1081
+ module Bukkits
1082
+ class Engine < ::Rails::Engine
1083
+ isolate_namespace Bukkits
1084
+ end
1085
+ end
1086
+ RUBY
1087
+
1088
+ @plugin . write "lib/bukkits/awesome.rb" , <<-RUBY
1089
+ module Bukkits
1090
+ module Awesome
1091
+ class Engine < ::Rails::Engine
1092
+ isolate_namespace Bukkits::Awesome
1093
+ end
1094
+ end
1095
+ end
1096
+ RUBY
1097
+
1098
+ app_file "config/routes.rb" , <<-RUBY
1099
+ Rails.application.routes.draw do
1100
+ mount Bukkits::Engine, at: "/bukkits"
1101
+ end
1102
+
1103
+ Bukkits::Engine.routes.draw do
1104
+ get "/foo" => "foo#index"
1105
+
1106
+ mount Bukkits::Awesome::Engine, at: "/awesome"
1107
+ end
1108
+
1109
+ Bukkits::Awesome::Engine.routes.draw do
1110
+ get "/bar", as: :bar, to: "bar#index"
1111
+ end
1112
+ RUBY
1113
+
1114
+ @plugin . write "app/controllers/bukkits/foo_controller.rb" , <<-RUBY
1115
+ class Bukkits::FooController < ActionController::Base
1116
+ def index
1117
+ render plain: bukkits_awesome.bar_path
1118
+ end
1119
+ end
1120
+ RUBY
1121
+
1122
+ @plugin . write "app/controllers/bukkits/awesome/bar_controller.rb" , <<-RUBY
1123
+ class Bukkits::Awesome::BarController < ActionController::Base
1124
+ def index
1125
+ render plain: "ok"
1126
+ end
1127
+ end
1128
+ RUBY
1129
+
1130
+ add_to_config ( "config.action_dispatch.show_exceptions = :none" )
1131
+
1132
+ boot_rails
1133
+
1134
+ get ( "/bukkits/foo" )
1135
+ assert_equal "/bukkits/awesome/bar" , last_response . body
1136
+ get ( "/bukkits/awesome/bar" )
1137
+ assert_equal "ok" , last_response . body
1138
+ end
1139
+
1073
1140
test "loading seed data" do
1074
1141
@plugin . write "db/seeds.rb" , <<-RUBY
1075
1142
Bukkits::Engine.config.bukkits_seeds_loaded = true
0 commit comments