eBooru/test/unit/exception_log_test.rb
Earlopain d2d6e83537
[Misc] Fix an exception during exception logging
This broke after the upgrade to rails 7.1 because of https://github.com/rails/rails/pull/46535
2024-04-11 19:10:57 +02:00

20 lines
700 B
Ruby

# frozen_string_literal: true
require "test_helper"
class ExceptionLogTest < ActiveSupport::TestCase
self.use_transactional_tests = false
should "log for query timeout errors with bind parameters" do
e = assert_raises(ActiveRecord::QueryCanceled) do
Post.connection.execute("SET STATEMENT_TIMEOUT = 50")
Post.from("pg_sleep(1), posts").where(description: "bind param").count
end
log = ExceptionLog.add(e, 1, ActionDispatch::TestRequest.new("rack.input" => "abc", "REMOTE_ADDR" => "127.0.0.1"))
assert_equal(["bind param"], log.extra_params["sql"]["binds"])
ensure
Post.connection.execute("SET STATEMENT_TIMEOUT = 3000")
ExceptionLog.destroy_all
end
end