Skip to content
Browse files

Set default asset_path only for engine

  • Loading branch information...
1 parent 36fcb77 commit 497b6af8818f656fdbca9ed2470c1c16ae5ff1cd @drogus drogus committed
Showing with 29 additions and 0 deletions.
  1. +1 −0 railties/lib/rails/application/configuration.rb
  2. +28 −0 railties/test/railties/engine_test.rb
View
1 railties/lib/rails/application/configuration.rb
@@ -23,6 +23,7 @@ def initialize(*)
@session_options = {}
@time_zone = "UTC"
@middleware = app_middleware
+ @asset_path = '/'
end
def asset_path=(value)
View
28 railties/test/railties/engine_test.rb
@@ -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"

0 comments on commit 497b6af

Please sign in to comment.
Something went wrong with that request. Please try again.