Skip to content

Commit 57168f3

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

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

spec/migration_lock_timeout/migration_spec.rb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@
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+
puts "SharpTest: #{ActiveRecord::Base.connection.class}"
13+
expect(ActiveRecord::Base.with_connection).to receive(:execute).
14+
with('BEGIN', 'TRANSACTION').
15+
and_call_original
16+
expect(ActiveRecord::Base.with_connection).to receive(:execute).
17+
with(/CREATE TABLE/).
1718
and_call_original
18-
expect(ActiveRecord::Base.connection).to receive(:execute).
19-
with(/CREATE TABLE/).
20-
and_call_original
19+
else
20+
expect(ActiveRecord::Base.connection).to receive(:execute).
21+
with('BEGIN', 'TRANSACTION').
22+
and_call_original
23+
expect(ActiveRecord::Base.connection).to receive(:execute).
24+
with(/CREATE TABLE/).
25+
and_call_original
26+
end
2127
end
2228

2329
RSpec.describe ActiveRecord::Migration do
24-
30+
before { ActiveRecord::Base.logger = Logger.new(STDOUT) }
2531
describe '#migrate' do
2632

2733
before(:each) do

0 commit comments

Comments
 (0)