From 4de8851289077239ecc91473bdba30f8cf6727bb Mon Sep 17 00:00:00 2001 From: Ben Pickles Date: Wed, 9 Oct 2013 11:16:22 +0100 Subject: Expose MiddlewareStack#unshift to environment configuration. --- railties/CHANGELOG.md | 4 ++++ railties/lib/rails/configuration.rb | 4 ++++ railties/test/application/middleware_test.rb | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index a4babbe8c3..4e6bf899af 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Expose MiddlewareStack#unshift to environment configuration. + + *Ben Pickles* + * Include `web-console` into newly generated applications' Gemfile. *Genadi Samokovarov* diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index c694513960..f5d7dede66 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -59,6 +59,10 @@ module Rails @operations << [__method__, args, block] end + def unshift(*args, &block) + @operations << [__method__, args, block] + end + def merge_into(other) #:nodoc: @operations.each do |operation, args, block| other.send(operation, *args, &block) diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 31a35a09bb..20d1d76d78 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -144,6 +144,12 @@ module ApplicationTests assert_equal "Rack::Config", middleware.second end + test 'unshift middleware' do + add_to_config 'config.middleware.unshift Rack::Config' + boot! + assert_equal 'Rack::Config', middleware.first + end + test "Rails.cache does not respond to middleware" do add_to_config "config.cache_store = :memory_store" boot! -- cgit v1.2.3