File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ module Rails
25
25
# ActiveRecord::Base.transaction(requires_new: true)
26
26
#
27
27
class PrivateTransactionOption < Base
28
- MSG = 'Do not use `ActiveRecord::Base.transaction(joinable: _) `.'
28
+ MSG = 'Use a negated `requires_new` option instead of the internal `joinable `.'
29
29
RESTRICT_ON_SEND = %i[ transaction ] . freeze
30
30
31
31
# @!method match_transaction_with_joinable(node)
Original file line number Diff line number Diff line change 3
3
RSpec . describe RuboCop ::Cop ::Rails ::PrivateTransactionOption , :config do
4
4
it 'registers an offense when using `joinable: false`' do
5
5
expect_offense ( <<~RUBY )
6
- ActiveRecord::Base.transaction(requires_new: true, joinable: false)
7
- ^^^^^^^^^^^^^^^ Do not use `ActiveRecord::Base.transaction(joinable: _)`.
6
+ ActiveRecord::Base.transaction(requires_new: true, joinable: false) do
7
+ ^^^^^^^^^^^^^^^ Use a negated `requires_new` option instead of the internal `joinable`.
8
+ # ...
9
+ end
8
10
RUBY
9
11
end
10
12
13
+ it 'registers an offense when using `joinable: false`' do
14
+ expect_offense ( <<~RUBY )
15
+ account.transaction(requires_new: true, joinable: false) do
16
+ ^^^^^^^^^^^^^^^ Use a negated `requires_new` option instead of the internal `joinable`.
17
+ # ...
18
+ end
19
+ RUBY
20
+ end
11
21
it 'does not register an offense when using only `requires_new: true`' do
12
22
expect_no_offenses ( <<~RUBY )
13
- ActiveRecord::Base.transaction(requires_new: true)
23
+ ActiveRecord::Base.transaction(requires_new: true) do
24
+ # ...
25
+ end
14
26
RUBY
15
27
end
16
28
end
You can’t perform that action at this time.
0 commit comments