]> git.openstreetmap.org Git - rails.git/blob - config/initializers/prosopite.rb
Merge remote-tracking branch 'upstream/pull/7491'
[rails.git] / config / initializers / prosopite.rb
1 # frozen_string_literal: true
2
3 # Fail tests on N+1 queries, apart from those with any of the files listed
4 # in test/prosopite_todo.yml in their call stack. That list should only
5 # ever shrink. Each of these is scanned separately:
6 #
7 #  * requests, whether made by ActionDispatch::IntegrationTest subclasses
8 #    (which includes the tests in test/controllers as well as
9 #    test/integration) or by the browser in system tests
10 #  * jobs performed by any test (see test/test_helper.rb)
11 #
12 # Test setup, such as creating records with factories, isn't scanned.
13 if Rails.env.test?
14   require "prosopite/middleware/rack"
15   Rails.application.config.middleware.use(Prosopite::Middleware::Rack)
16
17   Prosopite.raise = true
18   Prosopite.allow_stack_paths = YAML.load_file(Rails.root.join("test/prosopite_todo.yml")).map do |path|
19     # Match "/app/models/way.rb:123" but not "/app/models/old_way.rb:123"
20     "/#{path}:"
21   end
22 end