1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge remote branch 'drogus/engines'

This commit is contained in:
wycats 2010-09-11 03:24:50 -05:00
commit f6153f74da
9 changed files with 41 additions and 12 deletions

View file

@ -21,7 +21,7 @@ module ActionMailer
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

View file

@ -27,7 +27,7 @@ module ActionController
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) }

View file

@ -262,7 +262,7 @@ module ActionDispatch
module MountedHelpers
end
def mounted_helpers(name = nil)
def mounted_helpers(name = :main_app)
define_mounted_helper(name) if name
MountedHelpers
end

View file

@ -72,7 +72,7 @@ module TestGenerationPrefix
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 @@ module TestGenerationPrefix
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

View file

@ -23,6 +23,7 @@ module Rails
@session_options = {}
@time_zone = "UTC"
@middleware = app_middleware
@asset_path = '/'
end
def asset_path=(value)

View file

@ -61,7 +61,7 @@ module ApplicationTests
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

View file

@ -203,7 +203,7 @@ module ApplicationTests
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

View file

@ -281,6 +281,34 @@ module RailtiesTest
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 @@ module RailtiesTest
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

View file

@ -70,14 +70,14 @@ module ApplicationTests
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