lib/rubocop/cop/rails/transaction_exit_statement.rb in rubocop-rails-2.19.1 vs lib/rubocop/cop/rails/transaction_exit_statement.rb in rubocop-rails-2.20.0
- old
+ new
@@ -32,10 +32,15 @@
# # bad, as `with_lock` implicitly opens a transaction too
# user.with_lock do
# throw if user.active?
# end
#
+ # # bad, as `with_lock` implicitly opens a transaction too
+ # ApplicationRecord.with_lock do
+ # break if user.active?
+ # end
+ #
# # good
# ApplicationRecord.transaction do
# # Rollback
# raise "User is active" if user.active?
# end
@@ -89,10 +94,12 @@
statement_node.method_name
end
end
def nested_block?(statement_node)
- !statement_node.ancestors.find(&:block_type?).method?(:transaction)
+ block_node = statement_node.ancestors.find(&:block_type?)
+
+ RESTRICT_ON_SEND.none? { |name| block_node.method?(name) }
end
end
end
end
end