Skip to content

Commit 94a5f1a

Browse files
committed
Remove conditional, automatically remove connections
1 parent 4e97eab commit 94a5f1a

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

spec/migration_lock_timeout/migration_spec.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,12 @@
88
ACTIVE_RECORD_MIGRATION_CLASS = ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f]
99

1010
def expect_create_table
11-
if ActiveRecord.gem_version >= '7.1'
12-
expect(ActiveRecord::Base.connection).to receive(:execute).
13-
with('BEGIN').
14-
and_call_original
15-
expect(ActiveRecord::Base.connection).to receive(:execute).
16-
with(/CREATE TABLE/).
17-
and_call_original
18-
else
19-
expect(ActiveRecord::Base.connection).to receive(:execute).
20-
with('BEGIN', 'TRANSACTION').
21-
and_call_original
22-
expect(ActiveRecord::Base.connection).to receive(:execute).
23-
with(/CREATE TABLE/).
24-
and_call_original
25-
end
11+
expect(ActiveRecord::Base.connection).to receive(:execute).
12+
with('BEGIN', 'TRANSACTION').
13+
and_call_original
14+
expect(ActiveRecord::Base.connection).to receive(:execute).
15+
with(/CREATE TABLE/).
16+
and_call_original
2617
end
2718

2819
RSpec.describe ActiveRecord::Migration do

spec/migration_lock_timeout/spec_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
password: ENV['POSTGRES_DB_PASSWORD'],
1010
host: 'localhost'
1111
)
12-
DatabaseCleaner.strategy = :transaction
12+
DatabaseCleaner.strategy = :truncation
1313
DatabaseCleaner.clean_with(:truncation)
1414
end
1515

@@ -18,4 +18,10 @@
1818
example.run
1919
end
2020
end
21+
22+
if ActiveRecord.gem_version >= '7.1'
23+
config.after(:each) do |example|
24+
ActiveRecord::Base.remove_connection
25+
end
26+
end
2127
end

0 commit comments

Comments
 (0)