Skip to content

Commit d5e0644

Browse files
committed
Conditionalize for ActiveRecord 7.1+
- Also remove old conditional
1 parent c001b9c commit d5e0644

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

spec/migration_lock_timeout/migration_spec.rb

+16-11
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@
55
require 'strong_migrations' if Gem.loaded_specs.has_key? 'strong_migrations'
66
require_relative '../../lib/migration-lock-timeout'
77

8-
ACTIVE_RECORD_MIGRATION_CLASS = if ActiveRecord.gem_version < '5.0'
9-
ActiveRecord::Migration
10-
else
11-
ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f]
12-
end
8+
ACTIVE_RECORD_MIGRATION_CLASS = ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f]
139

1410
def expect_create_table
15-
expect(ActiveRecord::Base.connection).to receive(:execute).
16-
with('BEGIN', 'TRANSACTION').
11+
if ActiveRecord.gem_version >= '7.1'
12+
expect(ActiveRecord::Base.connection).to receive(:execute).
13+
with(/ROLLBACK/).
14+
and_call_original
15+
expect(ActiveRecord::Base.connection).to receive(:execute).
16+
with(/CREATE TABLE/).
1717
and_call_original
18-
expect(ActiveRecord::Base.connection).to receive(:execute).
19-
with(/CREATE TABLE/).
20-
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
2126
end
2227

2328
RSpec.describe ActiveRecord::Migration do
24-
29+
before { ActiveRecord::Base.logger = Logger.new(STDOUT) }
2530
describe '#migrate' do
2631

2732
before(:each) do

0 commit comments

Comments
 (0)