mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
don't establish a new connection when testing with sqlite3_mem
.
This fixes broken `rake test_sqlite3_mem` suite for Active Record. The problem is that that the old database with the schema is lost when establishing a new connection. Upon reconnting we are left with a blank database and tests down the line start failing.
This commit is contained in:
parent
93b38d54df
commit
b23330745b
1 changed files with 21 additions and 15 deletions
|
@ -34,24 +34,30 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_connect_with_url
|
def test_connect_with_url
|
||||||
original_connection = ActiveRecord::Base.remove_connection
|
skip "can't establish new connection when using memory db" if in_memory_db?
|
||||||
tf = Tempfile.open 'whatever'
|
begin
|
||||||
url = "sqlite3://#{tf.path}"
|
original_connection = ActiveRecord::Base.remove_connection
|
||||||
ActiveRecord::Base.establish_connection(url)
|
tf = Tempfile.open 'whatever'
|
||||||
assert ActiveRecord::Base.connection
|
url = "sqlite3://#{tf.path}"
|
||||||
ensure
|
ActiveRecord::Base.establish_connection(url)
|
||||||
tf.close
|
assert ActiveRecord::Base.connection
|
||||||
tf.unlink
|
ensure
|
||||||
ActiveRecord::Base.establish_connection(original_connection)
|
tf.close
|
||||||
|
tf.unlink
|
||||||
|
ActiveRecord::Base.establish_connection(original_connection)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_connect_memory_with_url
|
def test_connect_memory_with_url
|
||||||
original_connection = ActiveRecord::Base.remove_connection
|
skip "can't establish new connection when using memory db" if in_memory_db?
|
||||||
url = "sqlite3:///:memory:"
|
begin
|
||||||
ActiveRecord::Base.establish_connection(url)
|
original_connection = ActiveRecord::Base.remove_connection
|
||||||
assert ActiveRecord::Base.connection
|
url = "sqlite3:///:memory:"
|
||||||
ensure
|
ActiveRecord::Base.establish_connection(url)
|
||||||
ActiveRecord::Base.establish_connection(original_connection)
|
assert ActiveRecord::Base.connection
|
||||||
|
ensure
|
||||||
|
ActiveRecord::Base.establish_connection(original_connection)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_valid_column
|
def test_valid_column
|
||||||
|
|
Loading…
Reference in a new issue