aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/invalid_connection_test.rb
blob: f6fe7f0d7d7e1ef7a2d5f96dd7086adfd60dda2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require "cases/helper"
require "models/bird"

class TestAdapterWithInvalidConnection < ActiveRecord::TestCase
  self.use_transactional_fixtures = false

  def setup
    @spec = ActiveRecord::Base.connection_config
    non_existing_spec = {adapter: @spec[:adapter], database: "i_do_not_exist"}
    ActiveRecord::Base.establish_connection(non_existing_spec)
  end

  def teardown
    ActiveRecord::Base.establish_connection(@spec)
  end

  test "inspect on Model class does not raise" do
    assert_equal "Bird(no database connection)", Bird.inspect
  end
end