0.6.0
Features
- Added linear number of queries assertion.
Now you can set up an expectation of linear growth of the number of queries. It can be helpful when you already have N+1 and for some reason you cannot fix it right now, so you want to prevent it from growing. Example:
# RSpec
context "when has linear query", :n_plus_one do
populate { |n| create_list(:post, n) }
specify do
expect { Post.find_each { |p| p.user.name } }
.to perform_linear_number_of_queries(slope: 1)
end
end
# Minitest
def test_no_n_plus_one_error
populate = ->(n) { create_list(:post, n) }
assert_perform_linear_number_of_queries(slope: 1, populate: populate) do
Post.find_each { |p| p.user.name }
end
end
Fixes
- Added support for backticks in table names.
If your rails application uses backticks around table names in database queries, they will be correctly processed in verbose mode.