~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activerecord/test/cases/unconnected_test.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require "cases/helper"
2
 
 
3
 
class TestRecord < ActiveRecord::Base
4
 
end
5
 
 
6
 
class TestUnconnectedAdapter < ActiveRecord::TestCase
7
 
  self.use_transactional_fixtures = false
8
 
 
9
 
  def setup
10
 
    @underlying = ActiveRecord::Base.connection
11
 
    @specification = ActiveRecord::Base.remove_connection
12
 
  end
13
 
 
14
 
  def teardown
15
 
    @underlying = nil
16
 
    ActiveRecord::Base.establish_connection(@specification)
17
 
  end
18
 
 
19
 
  def test_connection_no_longer_established
20
 
    assert_raise(ActiveRecord::ConnectionNotEstablished) do
21
 
      TestRecord.find(1)
22
 
    end
23
 
 
24
 
    assert_raise(ActiveRecord::ConnectionNotEstablished) do
25
 
      TestRecord.new.save
26
 
    end
27
 
  end
28
 
 
29
 
  def test_underlying_adapter_no_longer_active
30
 
    assert !@underlying.active?, "Removed adapter should no longer be active"
31
 
  end
32
 
end