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 889d3e1
Show file tree
Hide file tree
Showing 2 changed files with 11 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
6 changes: 5 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,8 @@
example.run
end
end

config.after(:each) do |example|
ActiveRecord::Base.remove_connection
end
end

0 comments on commit 889d3e1

Please sign in to comment.