mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
stop swallowing exceptions in assert_queries. Methods that raise an
exception are unlikely to pass this assertion, but since the assertions raise an exception, the original exception is lost.
This commit is contained in:
parent
fe7e730862
commit
1ff5341385
1 changed files with 2 additions and 2 deletions
|
@ -35,8 +35,7 @@ module ActiveRecord
|
|||
def assert_queries(num = 1, options = {})
|
||||
ignore_none = options.fetch(:ignore_none) { num == :any }
|
||||
SQLCounter.clear_log
|
||||
yield
|
||||
ensure
|
||||
x = yield
|
||||
the_log = ignore_none ? SQLCounter.log_all : SQLCounter.log
|
||||
if num == :any
|
||||
assert_operator the_log.size, :>=, 1, "1 or more queries expected, but none were executed."
|
||||
|
@ -44,6 +43,7 @@ module ActiveRecord
|
|||
mesg = "#{the_log.size} instead of #{num} queries were executed.#{the_log.size == 0 ? '' : "\nQueries:\n#{the_log.join("\n")}"}"
|
||||
assert_equal num, the_log.size, mesg
|
||||
end
|
||||
x
|
||||
end
|
||||
|
||||
def assert_no_queries(&block)
|
||||
|
|
Loading…
Reference in a new issue