aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-01-14 18:00:58 +0100
committerYves Senn <yves.senn@gmail.com>2014-01-14 18:03:31 +0100
commitb23330745bddd6729f95fb8487e3ec4857e4bb58 (patch)
tree5a6ea109595204b395f46c4bf5d4d39a64abf783 /activerecord/test/cases/adapters
parent93b38d54df7133c1404b492c14f15034e5b8f40e (diff)
downloadrails-b23330745bddd6729f95fb8487e3ec4857e4bb58.tar.gz
rails-b23330745bddd6729f95fb8487e3ec4857e4bb58.tar.bz2
rails-b23330745bddd6729f95fb8487e3ec4857e4bb58.zip
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.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r--activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb36
1 files changed, 21 insertions, 15 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
index 0598ff25f8..082fe3cde5 100644
--- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
+++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
@@ -34,24 +34,30 @@ module ActiveRecord
end
def test_connect_with_url
- original_connection = ActiveRecord::Base.remove_connection
- tf = Tempfile.open 'whatever'
- url = "sqlite3://#{tf.path}"
- ActiveRecord::Base.establish_connection(url)
- assert ActiveRecord::Base.connection
- ensure
- tf.close
- tf.unlink
- ActiveRecord::Base.establish_connection(original_connection)
+ skip "can't establish new connection when using memory db" if in_memory_db?
+ begin
+ original_connection = ActiveRecord::Base.remove_connection
+ tf = Tempfile.open 'whatever'
+ url = "sqlite3://#{tf.path}"
+ ActiveRecord::Base.establish_connection(url)
+ assert ActiveRecord::Base.connection
+ ensure
+ tf.close
+ tf.unlink
+ ActiveRecord::Base.establish_connection(original_connection)
+ end
end
def test_connect_memory_with_url
- original_connection = ActiveRecord::Base.remove_connection
- url = "sqlite3:///:memory:"
- ActiveRecord::Base.establish_connection(url)
- assert ActiveRecord::Base.connection
- ensure
- ActiveRecord::Base.establish_connection(original_connection)
+ skip "can't establish new connection when using memory db" if in_memory_db?
+ begin
+ original_connection = ActiveRecord::Base.remove_connection
+ url = "sqlite3:///:memory:"
+ ActiveRecord::Base.establish_connection(url)
+ assert ActiveRecord::Base.connection
+ ensure
+ ActiveRecord::Base.establish_connection(original_connection)
+ end
end
def test_valid_column