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 e218e2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 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: 6 additions & 0 deletions spec/migration_lock_timeout/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 e218e2c

Please sign in to comment.