Skip to content

Commit

Permalink
Remove conditional, automatically remove connections
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-sharp committed Aug 7, 2024
1 parent 4e97eab commit 94a5f1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
21 changes: 6 additions & 15 deletions spec/migration_lock_timeout/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@
ACTIVE_RECORD_MIGRATION_CLASS = ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f]

def expect_create_table
if ActiveRecord.gem_version >= '7.1'
expect(ActiveRecord::Base.connection).to receive(:execute).
with('BEGIN').
and_call_original
expect(ActiveRecord::Base.connection).to receive(:execute).
with(/CREATE TABLE/).
and_call_original
else
expect(ActiveRecord::Base.connection).to receive(:execute).
with('BEGIN', 'TRANSACTION').
and_call_original
expect(ActiveRecord::Base.connection).to receive(:execute).
with(/CREATE TABLE/).
and_call_original
end
expect(ActiveRecord::Base.connection).to receive(:execute).
with('BEGIN', 'TRANSACTION').
and_call_original
expect(ActiveRecord::Base.connection).to receive(:execute).
with(/CREATE TABLE/).
and_call_original
end

RSpec.describe ActiveRecord::Migration do
Expand Down
8 changes: 7 additions & 1 deletion spec/migration_lock_timeout/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
password: ENV['POSTGRES_DB_PASSWORD'],
host: 'localhost'
)
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end

Expand All @@ -18,4 +18,10 @@
example.run
end
end

if ActiveRecord.gem_version >= '7.1'
config.after(:each) do |example|
ActiveRecord::Base.remove_connection
end
end
end

0 comments on commit 94a5f1a

Please sign in to comment.