class ApplicationTests::ApplicationRoutingTest
Public Instance Methods
app()
click to toggle source
# File railties/test/railties/mounted_engine_test.rb, line 194 def app @app ||= begin require "#{app_path}/config/environment" Quails.application end end
setup()
click to toggle source
# File railties/test/railties/mounted_engine_test.rb, line 11 def setup build_app add_to_config("config.action_dispatch.show_exceptions = false") @simple_plugin = engine "weblog" @plugin = engine "blog" @metrics_plugin = engine "metrics" app_file "config/routes.rb", <<-RUBY Quails.application.routes.draw do mount Weblog::Engine, :at => '/', :as => 'weblog' resources :posts get "/engine_route" => "application_generating#engine_route" get "/engine_route_in_view" => "application_generating#engine_route_in_view" get "/weblog_engine_route" => "application_generating#weblog_engine_route" get "/weblog_engine_route_in_view" => "application_generating#weblog_engine_route_in_view" get "/url_for_engine_route" => "application_generating#url_for_engine_route" get "/polymorphic_route" => "application_generating#polymorphic_route" get "/application_polymorphic_path" => "application_generating#application_polymorphic_path" scope "/:user", :user => "anonymous" do mount Blog::Engine => "/blog" end mount Metrics::Engine => "/metrics" root :to => 'main#index' end RUBY @simple_plugin.write "lib/weblog.rb", <<-RUBY module Weblog class Engine < ::Quails::Engine end end RUBY @simple_plugin.write "config/routes.rb", <<-RUBY Weblog::Engine.routes.draw do get '/weblog' => "weblogs#index", as: 'weblogs' end RUBY @simple_plugin.write "app/controllers/weblogs_controller.rb", <<-RUBY class WeblogsController < ActionController::Base def index render plain: request.url end end RUBY @metrics_plugin.write "lib/metrics.rb", <<-RUBY module Metrics class Engine < ::Quails::Engine isolate_namespace(Metrics) end end RUBY @metrics_plugin.write "config/routes.rb", <<-RUBY Metrics::Engine.routes.draw do get '/generate_blog_route', to: 'generating#generate_blog_route' get '/generate_blog_route_in_view', to: 'generating#generate_blog_route_in_view' end RUBY @metrics_plugin.write "app/controllers/metrics/generating_controller.rb", <<-RUBY module Metrics class GeneratingController < ActionController::Base def generate_blog_route render plain: blog.post_path(1) end def generate_blog_route_in_view render inline: "<%= blog.post_path(1) -%>" end end end RUBY @plugin.write "app/models/blog/post.rb", <<-RUBY module Blog class Post include ActiveModel::Model def id 44 end def persisted? true end end end RUBY @plugin.write "lib/blog.rb", <<-RUBY module Blog class Engine < ::Quails::Engine isolate_namespace(Blog) end end RUBY @plugin.write "config/routes.rb", <<-RUBY Blog::Engine.routes.draw do resources :posts get '/different_context', to: 'posts#different_context' get '/generate_application_route', to: 'posts#generate_application_route' get '/application_route_in_view', to: 'posts#application_route_in_view' get '/engine_polymorphic_path', to: 'posts#engine_polymorphic_path' get '/engine_asset_path', to: 'posts#engine_asset_path' end RUBY @plugin.write "app/controllers/blog/posts_controller.rb", <<-RUBY module Blog class PostsController < ActionController::Base def index render plain: blog.post_path(1) end def different_context render plain: blog.post_path(1, user: "ada") end def generate_application_route path = main_app.url_for(controller: "/main", action: "index", only_path: true) render plain: path end def application_route_in_view render inline: "<%= main_app.root_path %>" end def engine_polymorphic_path render plain: polymorphic_path(Post.new) end def engine_asset_path render inline: "<%= asset_path 'images/foo.png', skip_pipeline: true %>" end end end RUBY app_file "app/controllers/application_generating_controller.rb", <<-RUBY class ApplicationGeneratingController < ActionController::Base def engine_route render plain: blog.posts_path end def engine_route_in_view render inline: "<%= blog.posts_path %>" end def weblog_engine_route render plain: weblog.weblogs_path end def weblog_engine_route_in_view render inline: "<%= weblog.weblogs_path %>" end def url_for_engine_route render plain: blog.url_for(controller: "blog/posts", action: "index", user: "john", only_path: true) end def polymorphic_route render plain: polymorphic_url([blog, Blog::Post.new]) end def application_polymorphic_path render plain: polymorphic_path(Blog::Post.new) end end RUBY end
teardown()
click to toggle source
# File railties/test/railties/mounted_engine_test.rb, line 190 def teardown teardown_app end