Skip to content

Commit

Permalink
Add Prosopite
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Jul 3, 2023
1 parent 549cc38 commit 89b820b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ end

group :test do
gem 'faker', '~> 2.13'
gem 'pg_query', '~> 4.2.1'
gem 'prosopite', '~> 1.3.2'
gem 'shoulda-matchers', '~> 4.1', '>= 4.1.2'
gem 'simplecov', '~> 0.13.0', require: false
gem 'webmock', '~> 3.7', '>= 3.7.6'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ GEM
formtastic_i18n (0.7.0)
globalid (1.1.0)
activesupport (>= 5.0)
google-protobuf (3.23.3)
has_scope (0.8.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand Down Expand Up @@ -276,6 +277,9 @@ GEM
parser (3.1.2.1)
ast (~> 2.4.1)
pg (1.4.3)
pg_query (4.2.1)
google-protobuf (>= 3.22.3)
prosopite (1.3.2)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -481,6 +485,8 @@ DEPENDENCIES
oj (~> 3.9, >= 3.9.2)
pagy (~> 4.0)
pg (~> 1.1, >= 1.1.4)
pg_query (~> 4.2.1)
prosopite (~> 1.3.2)
pry-byebug (~> 3.9)
pry-rails (~> 0.3.9)
puma (~> 5.6)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ To illustrate, `bin/rails console` will run the console in the docker container
- [Letter Opener](https://github.com/ryanb/letter_opener) for previewing a mail in the browser
- [Oj](https://github.com/ohler55/oj) for optimized json
- [Pagy](https://github.com/ddnexus/pagy) for pagination
- [Prosopite](https://github.com/charkost/prosopite) to detect N+1 queries
- [Pry](https://github.com/pry/pry) for enhancing the ruby shell
- [Puma](https://github.com/puma/puma) for the server
- [Pundit](https://github.com/varvet/pundit) for authorization management
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/prosopite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

if Rails.env.test?
Rails.application.config.after_initialize do
Prosopite.rails_logger = true
Prosopite.raise = true
end
end
4 changes: 4 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

config.include Shoulda::Matchers::ActiveModel, type: :form
config.include Shoulda::Matchers::ActiveRecord, type: :form

# Detects N+1 queries
config.before { Prosopite.scan }
config.after { Prosopite.finish }
end

Shoulda::Matchers.configure do |config|
Expand Down

0 comments on commit 89b820b

Please sign in to comment.