diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-28 16:22:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-28 16:22:37 -0700 |
commit | ec0cacc2938cb7159ae6085fc653b2be906a748f (patch) | |
tree | e4d3b8a8069bb4870c9e8dd32eb0a5a3f904efe8 /activerecord | |
parent | 7b4866e0aef1ed8ec08fd9eac104df42bce3c1c9 (diff) | |
download | rails-ec0cacc2938cb7159ae6085fc653b2be906a748f.tar.gz rails-ec0cacc2938cb7159ae6085fc653b2be906a748f.tar.bz2 rails-ec0cacc2938cb7159ae6085fc653b2be906a748f.zip |
testing app delegation from the ConnectionManagement middleware
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/connection_management_test.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb index c5511673ac..82ea46b41f 100644 --- a/activerecord/test/cases/connection_management_test.rb +++ b/activerecord/test/cases/connection_management_test.rb @@ -3,24 +3,41 @@ require "cases/helper" module ActiveRecord module ConnectionAdapters class ConnectionManagementTest < ActiveRecord::TestCase + class App + attr_reader :calls + def initialize + @calls = [] + end + + def call(env) + @calls << env + [200, {}, [['hi mom']]] + end + end + def setup @env = {} - @app = stub('App') + @app = App.new @management = ConnectionManagement.new(@app) @connections_cleared = false ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true } end + def test_app_delegation + manager = ConnectionManagement.new(@app) + + manager.call @env + assert_equal [@env], @app.calls + end + test "clears active connections after each call" do - @app.expects(:call).with(@env) @management.call(@env) assert @connections_cleared end test "doesn't clear active connections when running in a test case" do @env['rack.test'] = true - @app.expects(:call).with(@env) @management.call(@env) assert !@connections_cleared end |