Don't reuse the same connection to drop the tables
The test can disconnect the connection so we can't reuse.
This commit is contained in:
parent
115d4a3994
commit
a34eb120f1
@ -15,10 +15,10 @@ class Sample < ActiveRecord::Base
|
||||
@abort, Thread.abort_on_exception = Thread.abort_on_exception, false
|
||||
Thread.report_on_exception, @original_report_on_exception = false, Thread.report_on_exception
|
||||
|
||||
@connection = ActiveRecord::Base.connection
|
||||
@connection.clear_cache!
|
||||
connection = ActiveRecord::Base.connection
|
||||
connection.clear_cache!
|
||||
|
||||
@connection.create_table("samples", force: true) do |t|
|
||||
connection.create_table("samples", force: true) do |t|
|
||||
t.integer "value"
|
||||
end
|
||||
|
||||
@ -27,7 +27,7 @@ class Sample < ActiveRecord::Base
|
||||
|
||||
teardown do
|
||||
ActiveRecord::Base.clear_active_connections!
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
ActiveRecord::Base.connection.drop_table "samples", if_exists: true
|
||||
|
||||
Thread.abort_on_exception = @abort
|
||||
Thread.report_on_exception = @original_report_on_exception
|
||||
|
@ -15,12 +15,12 @@ class Sample < ActiveRecord::Base
|
||||
@abort, Thread.abort_on_exception = Thread.abort_on_exception, false
|
||||
Thread.report_on_exception, @original_report_on_exception = false, Thread.report_on_exception
|
||||
|
||||
@connection = ActiveRecord::Base.connection
|
||||
@connection.clear_cache!
|
||||
connection = ActiveRecord::Base.connection
|
||||
connection.clear_cache!
|
||||
|
||||
@connection.transaction do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
@connection.create_table("samples") do |t|
|
||||
connection.transaction do
|
||||
connection.drop_table "samples", if_exists: true
|
||||
connection.create_table("samples") do |t|
|
||||
t.integer "value"
|
||||
end
|
||||
end
|
||||
@ -29,7 +29,7 @@ class Sample < ActiveRecord::Base
|
||||
end
|
||||
|
||||
teardown do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
ActiveRecord::Base.connection.drop_table "samples", if_exists: true
|
||||
|
||||
Thread.abort_on_exception = @abort
|
||||
Thread.report_on_exception = @original_report_on_exception
|
||||
|
@ -16,11 +16,11 @@ class Sample < ActiveRecord::Base
|
||||
@abort, Thread.abort_on_exception = Thread.abort_on_exception, false
|
||||
Thread.report_on_exception, @original_report_on_exception = false, Thread.report_on_exception
|
||||
|
||||
@connection = ActiveRecord::Base.connection
|
||||
connection = ActiveRecord::Base.connection
|
||||
|
||||
@connection.transaction do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
@connection.create_table("samples") do |t|
|
||||
connection.transaction do
|
||||
connection.drop_table "samples", if_exists: true
|
||||
connection.create_table("samples") do |t|
|
||||
t.integer "value"
|
||||
end
|
||||
end
|
||||
@ -29,7 +29,7 @@ class Sample < ActiveRecord::Base
|
||||
end
|
||||
|
||||
teardown do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
ActiveRecord::Base.connection.drop_table "samples", if_exists: true
|
||||
|
||||
Thread.abort_on_exception = @abort
|
||||
Thread.report_on_exception = @original_report_on_exception
|
||||
|
@ -16,11 +16,11 @@ class Sample < ActiveRecord::Base
|
||||
@abort, Thread.abort_on_exception = Thread.abort_on_exception, false
|
||||
Thread.report_on_exception, @original_report_on_exception = false, Thread.report_on_exception
|
||||
|
||||
@connection = ActiveRecord::Base.connection
|
||||
connection = ActiveRecord::Base.connection
|
||||
|
||||
@connection.transaction do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
@connection.create_table("samples") do |t|
|
||||
connection.transaction do
|
||||
connection.drop_table "samples", if_exists: true
|
||||
connection.create_table("samples") do |t|
|
||||
t.integer "value"
|
||||
end
|
||||
end
|
||||
@ -29,7 +29,7 @@ class Sample < ActiveRecord::Base
|
||||
end
|
||||
|
||||
teardown do
|
||||
@connection.drop_table "samples", if_exists: true
|
||||
ActiveRecord::Base.connection.drop_table "samples", if_exists: true
|
||||
|
||||
Thread.abort_on_exception = @abort
|
||||
Thread.report_on_exception = @original_report_on_exception
|
||||
|
Loading…
Reference in New Issue
Block a user