diff --git a/lib/mongoid/railtie.rb b/lib/mongoid/railtie.rb index 40a49eafbd..95e1543f5b 100644 --- a/lib/mongoid/railtie.rb +++ b/lib/mongoid/railtie.rb @@ -118,11 +118,7 @@ def self.rescue_responses # Need to include the Mongoid identity map middleware. initializer "include the identity map" do |app| - if ::Mongoid.running_with_passenger? - app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap::Passenger" - else - app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap" - end + app.config.middleware.use "Rack::Mongoid::Middleware::IdentityMap" end # Instantitate any registered observers after Rails initialization and diff --git a/lib/rack/mongoid.rb b/lib/rack/mongoid.rb index 9b2708702c..a054a4963f 100644 --- a/lib/rack/mongoid.rb +++ b/lib/rack/mongoid.rb @@ -1,3 +1,2 @@ # encoding: utf-8 -require "rack/mongoid/proxy" require "rack/mongoid/middleware/identity_map" diff --git a/lib/rack/mongoid/middleware/identity_map.rb b/lib/rack/mongoid/middleware/identity_map.rb index 31a87ad5f3..507cd240b0 100644 --- a/lib/rack/mongoid/middleware/identity_map.rb +++ b/lib/rack/mongoid/middleware/identity_map.rb @@ -31,48 +31,7 @@ def initialize(app) # # @since 2.1.0 def call(env) - begin - response = @app.call(env) - response[2] = ::Rack::Mongoid::Proxy.new(response[2]) do - ::Mongoid::IdentityMap.clear - end - rescue - ::Mongoid::IdentityMap.clear - raise - end - response - end - - # Passenger 3 does not execute the block provided to a Rack::BodyProxy - # so the identity map never gets cleared. Since there's no streaming - # support in it anyways we do not need the proxy functionality. - class Passenger - - # Initialize the new middleware. - # - # @example Init the middleware. - # IdentityMap.new(app) - # - # @param [ Object ] app The application. - # - # @since 3.0.11 - def initialize(app) - @app = app - end - - # Make the request with the provided environment. - # - # @example Make the request. - # identity_map.call(env) - # - # @param [ Object ] env The environment. - # - # @return [ Array ] The status, headers, and response. - # - # @since 3.0.11 - def call(env) - ::Mongoid.unit_of_work { @app.call(env) } - end + ::Mongoid.unit_of_work { @app.call(env) } end end end diff --git a/spec/rack/mongoid/middleware/identity_map_spec.rb b/spec/rack/mongoid/middleware/identity_map_spec.rb index 7570cc4a2a..22050c6449 100644 --- a/spec/rack/mongoid/middleware/identity_map_spec.rb +++ b/spec/rack/mongoid/middleware/identity_map_spec.rb @@ -20,42 +20,6 @@ describe "#call" do - module Rack - class BodyProxy - def initialize(body, &block) - @body, @block, @closed = body, block, false - end - - def respond_to?(*args) - return false if args.first.to_s =~ /^to_ary$/ - super or @body.respond_to?(*args) - end - - def close - return if @closed - @closed = true - begin - @body.close if @body.respond_to? :close - ensure - @block.call - end - end - - def closed? - @closed - end - - def each(*args, &block) - @body.each(*args, &block) - end - - def method_missing(*args, &block) - super if args.first.to_s =~ /^to_ary$/ - @body.__send__(*args, &block) - end - end - end - let(:middleware) do klass.new(app) end @@ -79,7 +43,7 @@ def method_missing(*args, &block) end it "returns the call with the body proxy" do - result[2].should be_a(Rack::BodyProxy) + result.should eq([]) end it "clears out the identity map" do