File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
activerecord/lib/active_record/testing Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,18 @@ module QueryAssertions
11
11
# # Check for any number of queries
12
12
# assert_queries_count { Post.first }
13
13
#
14
- # If the +:include_schema+ option is provided, any queries (including schema related) are counted.
14
+ # Any unmaterialized transactions will be materialized to ensure only
15
+ # queries attempted intside the block are counted.
16
+ #
17
+ # If the +:include_schema+ option is provided, any queries (including
18
+ # schema related) are counted. Setting this option also skips leasing a
19
+ # connection to materialize pending transactions since we want to count
20
+ # queries executed at connection open (e.g., type map).
15
21
#
16
22
# assert_queries_count(1, include_schema: true) { Post.columns }
17
23
#
18
24
def assert_queries_count ( count = nil , include_schema : false , &block )
19
- ActiveRecord ::Base . lease_connection . materialize_transactions
25
+ ActiveRecord ::Base . lease_connection . materialize_transactions unless include_schema
20
26
21
27
counter = SQLCounter . new
22
28
ActiveSupport ::Notifications . subscribed ( counter , "sql.active_record" ) do
You can’t perform that action at this time.
0 commit comments