mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Updated tests to use scope(:module => :engine_name) instead of namespace and updated mounted engine tests to actually use the namespacing
This commit is contained in:
parent
b1c66f060b
commit
16dcaf8368
2 changed files with 26 additions and 21 deletions
|
@ -390,7 +390,7 @@ module RailtiesTest
|
||||||
|
|
||||||
@plugin.write "config/routes.rb", <<-RUBY
|
@plugin.write "config/routes.rb", <<-RUBY
|
||||||
Bukkits::Engine.routes.draw do
|
Bukkits::Engine.routes.draw do
|
||||||
namespace(:bukkits, :path => nil, :shallow_path => nil, :as => nil) do
|
scope(:module => :bukkits) do
|
||||||
match "/foo" => "foo#index", :as => "foo"
|
match "/foo" => "foo#index", :as => "foo"
|
||||||
match "/foo/show" => "foo#show"
|
match "/foo/show" => "foo#show"
|
||||||
match "/from_app" => "foo#from_app"
|
match "/from_app" => "foo#from_app"
|
||||||
|
|
|
@ -19,7 +19,7 @@ module ApplicationTests
|
||||||
match "/engine_route_in_view" => "application_generating#engine_route_in_view"
|
match "/engine_route_in_view" => "application_generating#engine_route_in_view"
|
||||||
match "/url_for_engine_route" => "application_generating#url_for_engine_route"
|
match "/url_for_engine_route" => "application_generating#url_for_engine_route"
|
||||||
scope "/:user", :user => "anonymous" do
|
scope "/:user", :user => "anonymous" do
|
||||||
mount Blog::Engine => "/blog", :as => "blog_engine"
|
mount Blog::Engine => "/blog"
|
||||||
end
|
end
|
||||||
root :to => 'main#index'
|
root :to => 'main#index'
|
||||||
end
|
end
|
||||||
|
@ -28,34 +28,39 @@ module ApplicationTests
|
||||||
@plugin.write "lib/blog.rb", <<-RUBY
|
@plugin.write "lib/blog.rb", <<-RUBY
|
||||||
module Blog
|
module Blog
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
|
namespace(Blog)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
@plugin.write "config/routes.rb", <<-RUBY
|
@plugin.write "config/routes.rb", <<-RUBY
|
||||||
Blog::Engine.routes.draw do
|
Blog::Engine.routes.draw do
|
||||||
resources :posts do
|
scope(:module => :blog) do
|
||||||
get :generate_application_route
|
resources :posts do
|
||||||
get :application_route_in_view
|
get :generate_application_route
|
||||||
|
get :application_route_in_view
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
@plugin.write "app/controllers/posts_controller.rb", <<-RUBY
|
@plugin.write "app/controllers/blog/posts_controller.rb", <<-RUBY
|
||||||
class PostsController < ActionController::Base
|
module Blog
|
||||||
def index
|
class PostsController < ActionController::Base
|
||||||
render :text => blog_engine.post_path(1)
|
def index
|
||||||
end
|
render :text => blog.post_path(1)
|
||||||
|
end
|
||||||
|
|
||||||
def generate_application_route
|
def generate_application_route
|
||||||
path = app.url_for(:controller => "main",
|
path = app.url_for(:controller => "/main",
|
||||||
:action => "index",
|
:action => "index",
|
||||||
:only_path => true)
|
:only_path => true)
|
||||||
render :text => path
|
render :text => path
|
||||||
end
|
end
|
||||||
|
|
||||||
def application_route_in_view
|
def application_route_in_view
|
||||||
render :inline => "<%= app.root_path %>"
|
render :inline => "<%= app.root_path %>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
@ -63,15 +68,15 @@ module ApplicationTests
|
||||||
app_file "app/controllers/application_generating_controller.rb", <<-RUBY
|
app_file "app/controllers/application_generating_controller.rb", <<-RUBY
|
||||||
class ApplicationGeneratingController < ActionController::Base
|
class ApplicationGeneratingController < ActionController::Base
|
||||||
def engine_route
|
def engine_route
|
||||||
render :text => blog_engine.posts_path
|
render :text => blog.posts_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def engine_route_in_view
|
def engine_route_in_view
|
||||||
render :inline => "<%= blog_engine.posts_path %>"
|
render :inline => "<%= blog.posts_path %>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def url_for_engine_route
|
def url_for_engine_route
|
||||||
render :text => blog_engine.url_for(:controller => "posts", :action => "index", :user => "john", :only_path => true)
|
render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
Loading…
Reference in a new issue