Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert back to original middleware [ #2445 ]

  • Loading branch information...
commit a04fc849b5ddf0162c5d52705901f3d8a3cb33ec 1 parent 651f2d4
Durran Jordan durran authored
6 lib/mongoid/railtie.rb
View
@@ -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
1  lib/rack/mongoid.rb
View
@@ -1,3 +1,2 @@
# encoding: utf-8
-require "rack/mongoid/proxy"
require "rack/mongoid/middleware/identity_map"
43 lib/rack/mongoid/middleware/identity_map.rb
View
@@ -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
38 spec/rack/mongoid/middleware/identity_map_spec.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.