提交 f6153f74 编写于 作者: W wycats

Merge remote branch 'drogus/engines'

......@@ -21,7 +21,7 @@ class Railtie < Rails::Railtie
ActiveSupport.on_load(:action_mailer) do
include AbstractController::UrlFor
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
include app.routes.mounted_helpers(:app)
include app.routes.mounted_helpers
options.each { |k,v| send("#{k}=", v) }
end
end
......
......@@ -27,7 +27,7 @@ class Railtie < Rails::Railtie
options.page_cache_directory ||= paths.public.to_a.first
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers(:app)
include app.routes.mounted_helpers
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
extend ::ActionController::Railties::Paths.with(app)
options.each { |k,v| send("#{k}=", v) }
......
......@@ -262,7 +262,7 @@ def install_helpers(destinations = [ActionController::Base, ActionView::Base], r
module MountedHelpers
end
def mounted_helpers(name = nil)
def mounted_helpers(name = :main_app)
define_mounted_helper(name) if name
MountedHelpers
end
......
......@@ -72,7 +72,7 @@ def klass.name; self end
class ::InsideEngineGeneratingController < ActionController::Base
include BlogEngine.routes.url_helpers
include RailsApplication.routes.mounted_helpers(:app)
include RailsApplication.routes.mounted_helpers
def index
render :text => posts_path
......@@ -83,9 +83,9 @@ def show
end
def url_to_application
path = app.url_for( :controller => "outside_engine_generating",
:action => "index",
:only_path => true)
path = main_app.url_for(:controller => "outside_engine_generating",
:action => "index",
:only_path => true)
render :text => path
end
......
......@@ -23,6 +23,7 @@ def initialize(*)
@session_options = {}
@time_zone = "UTC"
@middleware = app_middleware
@asset_path = '/'
end
def asset_path=(value)
......
......@@ -61,7 +61,7 @@ def notify
require "#{app_path}/config/environment"
assert Foo.method_defined?(:foo_path)
assert Foo.method_defined?(:app)
assert Foo.method_defined?(:main_app)
assert_equal ["notify"], Foo.action_methods
end
......
......@@ -203,7 +203,7 @@ def baz
assert_equal 'bar', last_response.body
app_file 'config/routes.rb', <<-RUBY
AppTemplate::Application.routes.draw do |map|
AppTemplate::Application.routes.draw do
match 'foo', :to => 'foo#baz'
end
RUBY
......
......@@ -281,6 +281,34 @@ def index
assert_equal expected, stripped_body
end
test "default application's asset_path" do
@plugin.write "config/routes.rb", <<-RUBY
Bukkits::Engine.routes.draw do
match "/foo" => "foo#index"
end
RUBY
@plugin.write "app/controllers/foo_controller.rb", <<-RUBY
class FooController < ActionController::Base
def index
end
end
RUBY
@plugin.write "app/views/foo/index.html.erb", <<-RUBY
<%= compute_public_path("/foo", "") %>
RUBY
boot_rails
env = Rack::MockRequest.env_for("/foo")
response = Bukkits::Engine.call(env)
stripped_body = response[2].body.strip
expected = "/bukkits/foo"
assert_equal expected, stripped_body
end
test "engine's files are served via ActionDispatch::Static" do
add_to_config "config.serve_static_assets = true"
......@@ -437,7 +465,7 @@ def from_app
end
def routes_helpers_in_view
render :inline => "<%= foo_path %>, <%= app.bar_path %>"
render :inline => "<%= foo_path %>, <%= main_app.bar_path %>"
end
def polymorphic_path_without_namespace
......
......@@ -70,14 +70,14 @@ def index
end
def generate_application_route
path = app.url_for(:controller => "/main",
path = main_app.url_for(:controller => "/main",
:action => "index",
:only_path => true)
render :text => path
end
def application_route_in_view
render :inline => "<%= app.root_path %>"
render :inline => "<%= main_app.root_path %>"
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册