diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 15 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 60 |
2 files changed, 75 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 63d53fff90..6bf56f7052 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -260,5 +260,20 @@ module ApplicationTests get "/" assert_not_equal res, last_response.body end + + test "config.asset_path is not passed through env" do + make_basic_app do |app| + app.config.asset_path = "/omg%s" + end + + class ::OmgController < ActionController::Base + def index + render :inline => "<%= image_path('foo.jpg') %>" + end + end + + get "/" + assert_equal "/omg/images/foo.jpg", last_response.body + end end end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 4257a9fa83..3df6e110d5 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -199,5 +199,65 @@ module RailtiesTest assert_equal Rails.application.routes, env['action_dispatch.routes'] end + + test "it allows to set asset_path" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + class Engine < ::Rails::Engine + config.asset_path = "/bukkits%s" + end + end + RUBY + + + @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 + render :index + end + end + RUBY + + @plugin.write "app/views/foo/index.html.erb", <<-RUBY + <%= compute_public_path("/foo", "") %> + <%= image_path("foo.png") %> + <%= javascript_include_tag("foo") %> + <%= stylesheet_link_tag("foo") %> + RUBY + + + app_file "app/controllers/bar_controller.rb", <<-RUBY + class BarController < ActionController::Base + def index + render :index + end + end + RUBY + + app_file "app/views/bar/index.html.erb", <<-RUBY + <%= compute_public_path("/foo", "") %> + RUBY + + add_to_config 'config.asset_path = "/omg%s"' + + boot_rails + + env = Rack::MockRequest.env_for("/foo") + response = Bukkits::Engine.call(env) + stripped_body = response[2].body.split("\n").map(&:strip).join("\n") + + expected = "/omg/bukkits/foo\n" + + "/omg/bukkits/images/foo.png\n" + + "<script src=\"/omg/bukkits/javascripts/foo.js\" type=\"text/javascript\"></script>\n" + + "<link href=\"/omg/bukkits/stylesheets/foo.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />" + assert_equal expected, stripped_body + + end end end |