diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-06-22 23:51:28 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:03 +0200 |
commit | ad6be0876271f86e76c89645a0106b85c9d77ad7 (patch) | |
tree | fcbe3b9d4e0bd5d7b12f6e293e1077b4893a9320 /railties/test | |
parent | f7af75976a9117aa1cb294114af4f99a1d28f1cd (diff) | |
download | rails-ad6be0876271f86e76c89645a0106b85c9d77ad7.tar.gz rails-ad6be0876271f86e76c89645a0106b85c9d77ad7.tar.bz2 rails-ad6be0876271f86e76c89645a0106b85c9d77ad7.zip |
Made Engine valid rack app with its own middleware stack
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 7410a10712..08ba308bc4 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -50,5 +50,40 @@ module RailtiesTest assert index < initializers.index { |i| i.name == :build_middleware_stack } end + + class Upcaser + def initialize(app) + @app = app + end + + def call(env) + response = @app.call(env) + response[2].upcase! + response + end + end + + test "engine is a rack app and can have his own middleware stack" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + class Engine < ::Rails::Engine + endpoint lambda { |env| [200, {'Content-Type' => 'text/html'}, 'Hello World'] } + + config.middleware.use ::RailtiesTest::EngineTest::Upcaser + end + end + RUBY + + boot_rails + + Rails::Application.routes.draw do |map| + mount(Bukkits::Engine => "/bukkits") + end + + env = Rack::MockRequest.env_for("/bukkits") + response = Rails::Application.call(env) + + assert_equal "HELLO WORLD", response[2] + end end end |