Skip to content

Commit

Permalink
Merge pull request #30 from grosser/grosser/log
Browse files Browse the repository at this point in the history
make spec log not duplicate
  • Loading branch information
grosser authored Jan 16, 2024
2 parents 70ca910 + 430fa24 commit 7c0580c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
LOG = []

ActiveRecord::ConnectionAdapters::SQLite3Adapter.class_eval do
alias_method :exec_query_without_log, :exec_query
def exec_query(query, *args, **kwargs, &block)
LOG << query
exec_query_without_log(query, *args, **kwargs, &block)
end

# Rails 7.1.
# Rails 7.1
if ActiveRecord::ConnectionAdapters::SQLite3Adapter.method_defined?(:internal_exec_query)
alias_method :internal_exec_query_without_log, :internal_exec_query
def internal_exec_query(query, *args, **kwargs, &block)
LOG << query
internal_exec_query_without_log(query, *args, **kwargs, &block)
end
else
alias_method :exec_query_without_log, :exec_query
def exec_query(query, *args, **kwargs, &block)
LOG << query
exec_query_without_log(query, *args, **kwargs, &block)
end
end
end

Expand Down

0 comments on commit 7c0580c

Please sign in to comment.