diff --git a/Gemfile b/Gemfile index 79b7728..541628e 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,8 @@ group :development do gem 'listen', '~> 3.5' gem 'spring-watcher-listen', '~> 2.0.0' gem 'binding_of_caller' + gem 'derailed_benchmarks' + gem 'stackprof' end group :test do @@ -50,6 +52,9 @@ group :test do gem "launchy" gem "show_me_the_cookies", '~> 5.0.1' gem "timecop" + gem 'fasterer', require: false + gem 'rails_best_practices' + end group :development, :test do @@ -58,6 +63,7 @@ group :development, :test do gem 'simplecov' gem 'rubocop-performance' gem 'rubocop-rails' + gem 'bullet' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index e5f3499..4cfed88 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,7 @@ GEM execjs (~> 2) base64 (0.2.0) benchmark (0.4.0) + benchmark-ips (2.14.0) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -96,6 +97,9 @@ GEM bugsnag (6.27.1) concurrent-ruby (~> 1.0) builder (3.3.0) + bullet (8.0.1) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) byebug (11.1.3) capybara (3.40.0) addressable @@ -118,6 +122,8 @@ GEM ssrf_filter (~> 1.0) childprocess (5.1.0) logger (~> 1.5) + code_analyzer (0.5.5) + sexp_processor concurrent-ruby (1.3.5) connection_pool (2.5.0) crass (1.0.6) @@ -129,6 +135,24 @@ GEM database_cleaner-core (2.0.1) date (3.4.1) debug_inspector (1.2.0) + derailed_benchmarks (2.2.1) + base64 + benchmark-ips (~> 2) + bigdecimal + drb + get_process_mem + heapy (~> 0) + logger + memory_profiler (>= 0, < 2) + mini_histogram (>= 0.3.0) + mutex_m + ostruct + rack (>= 1) + rack-test + rake (> 10, < 14) + ruby-statistics (>= 4.0.1) + ruby2_keywords + thor (>= 0.19, < 2) diff-lcs (1.5.1) docile (1.4.1) dotenv (3.1.2) @@ -140,6 +164,7 @@ GEM activemodel encryptor (3.0.0) erubi (1.13.1) + erubis (2.7.0) execjs (2.10.0) factory_bot (6.5.1) activesupport (>= 6.1.0) @@ -150,6 +175,8 @@ GEM logger faraday-net_http (3.1.1) net-http + fasterer (0.11.0) + ruby_parser (>= 3.19.1) ffi (1.17.0) ffi (1.17.0-aarch64-linux-gnu) ffi (1.17.0-aarch64-linux-musl) @@ -161,9 +188,14 @@ GEM ffi (1.17.0-x86_64-darwin) ffi (1.17.0-x86_64-linux-gnu) ffi (1.17.0-x86_64-linux-musl) + get_process_mem (1.0.0) + bigdecimal (>= 2.0) + ffi (~> 1.0) globalid (1.2.1) activesupport (>= 6.1) hashie (5.0.0) + heapy (0.2.0) + thor i18n (1.14.7) concurrent-ruby (~> 1.0) image_processing (1.13.0) @@ -181,6 +213,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.10.2) jwt (2.8.2) base64 kgio (2.11.4) @@ -205,12 +238,15 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) + memory_profiler (1.1.0) + mini_histogram (0.3.1) mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.8) minitest (5.25.4) multi_xml (0.7.1) bigdecimal (~> 3.1) + mutex_m (0.3.0) net-http (0.4.1) uri net-imap (0.5.6) @@ -262,6 +298,7 @@ GEM omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) omniauth (~> 2.0) + ostruct (0.6.1) parallel (1.26.3) parser (3.3.7.1) ast (~> 2.4.1) @@ -314,6 +351,14 @@ GEM rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging + rails_best_practices (1.23.2) + activesupport + code_analyzer (~> 0.5.5) + erubis + i18n + json + require_all (~> 3.0) + ruby-progressbar rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (8.0.1) @@ -338,6 +383,7 @@ GEM io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) + require_all (3.0.0) rexml (3.4.1) rouge (4.3.0) rspec-core (3.13.0) @@ -376,9 +422,14 @@ GEM rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.13.0) + ruby-statistics (4.1.0) ruby-vips (2.2.2) ffi (~> 1.12) logger + ruby2_keywords (0.0.5) + ruby_parser (3.21.1) + racc (~> 1.5) + sexp_processor (~> 4.16) rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) @@ -397,6 +448,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sexp_processor (4.17.3) show_me_the_cookies (5.0.1) capybara (>= 2, < 4) simple_form (5.3.1) @@ -425,6 +477,7 @@ GEM activesupport (>= 6.1) sprockets (>= 3.0.0) ssrf_filter (1.1.2) + stackprof (0.2.27) stringio (3.1.5) thor (1.3.2) tilt (2.4.0) @@ -438,6 +491,7 @@ GEM unicorn (6.1.0) kgio (~> 2.6) raindrops (~> 0.7) + uniform_notifier (1.16.0) uri (1.0.3) useragent (0.16.11) version_gem (1.1.4) @@ -479,15 +533,18 @@ DEPENDENCIES bootstrap-sass (~> 3.4.1) bootstrap-scss bugsnag + bullet byebug capybara capybara-selenium carrierwave database_cleaner + derailed_benchmarks dotenv-rails email_validator factory_bot faker + fasterer jbuilder jquery-rails launchy @@ -501,6 +558,7 @@ DEPENDENCIES puma (~> 6.4.3) rails (~> 8.0.1) rails_12factor + rails_best_practices recaptcha rspec-rails rubocop @@ -513,6 +571,7 @@ DEPENDENCIES simplecov skylight spring-watcher-listen (~> 2.0.0) + stackprof timecop tzinfo-data uglifier (>= 1.3.0) diff --git a/app/views/secret_mailer/consumnation_notification.html.erb b/app/views/secret_mailer/consumnation_notification.html.erb index 32e4059..a05c982 100644 --- a/app/views/secret_mailer/consumnation_notification.html.erb +++ b/app/views/secret_mailer/consumnation_notification.html.erb @@ -4,12 +4,12 @@

This email is to notify you that <%= @secret.to_email %> viewed a secret that you shared with them via <%= link_to("SecretLink.org", "https://SecretLink.org") %>.

-<% if @secret.title.present? %> +<% if @secret.title? %>

The title of the viewed secret was: <%= @secret.title %>

<% end %> -<% if @secret.comments.present? %> +<% if @secret.comments? %>

The comments on the viewed secret were:

@@ -18,7 +18,7 @@ <% end %>

- This secret was created by you <%= time_ago_in_words(@secret.created_at) %> ago. + This secret was created by you <%= distance_of_time_in_words(Time.zone.now, @secret.created_at) %> ago.

The encrypted information has now been deleted from the database. diff --git a/app/views/secret_mailer/consumnation_notification.text.erb b/app/views/secret_mailer/consumnation_notification.text.erb index 0952c30..1026c2f 100644 --- a/app/views/secret_mailer/consumnation_notification.text.erb +++ b/app/views/secret_mailer/consumnation_notification.text.erb @@ -2,18 +2,18 @@ Hello <%= @secret.from_email %> This email is to notify you that <%= @secret.to_email %> viewed a secret that you shared with them via SecretLink.org. -<% if @secret.title.present? %> +<% if @secret.title? %> The title of the viewed secret was: <%= @secret.title %> <% end %> -<% if @secret.comments.present? %> +<% if @secret.comments? %> The comments on the viewed secret were: ------------------------------------------ <%= @secret.comments %> ------------------------------------------ <% end %> -This secret was created by you <%= time_ago_in_words(@secret.created_at) %> ago. +This secret was created by you <%= distance_of_time_in_words(Time.now, @secret.created_at) %> ago. The encrypted information has now been deleted from the database. diff --git a/app/views/secret_mailer/secret_notification.html.erb b/app/views/secret_mailer/secret_notification.html.erb index c7a98b5..91a1a34 100644 --- a/app/views/secret_mailer/secret_notification.html.erb +++ b/app/views/secret_mailer/secret_notification.html.erb @@ -6,12 +6,12 @@ <%= @secret.from_email %> has shared a secret with you via <%= link_to("SecretLink.org", "https://SecretLink.org") %>.

-<% if @secret.title.present? %> +<% if @secret.title? %>

Title: <%= @secret.title %>

<% end %> -<% if @secret.comments.present? %> +<% if @secret.comments? %>

Comments:

@@ -30,7 +30,7 @@ It can only be viewed once and will then be removed from the database.

-<% if @secret.expire_at.present? %> +<% if @secret.expire_at? %>

It will also expire and be removed if not accessed before <%= @secret.expire_at.strftime('%d %B %Y') %>.

diff --git a/app/views/secret_mailer/secret_notification.text.erb b/app/views/secret_mailer/secret_notification.text.erb index e1dfe98..bdf5d62 100644 --- a/app/views/secret_mailer/secret_notification.text.erb +++ b/app/views/secret_mailer/secret_notification.text.erb @@ -3,11 +3,11 @@ Hello <%= @secret.to_email %> <%= @secret.from_email %> has shared a secret with you via SecretLink.org. -<% if @secret.title.present? %> +<% if @secret.title? %> Title: <%= @secret.title %> <% end %> -<% if @secret.comments.present? %> +<% if @secret.comments? %> Comments: ------------------------------------------ <%= @secret.comments %> @@ -20,7 +20,7 @@ This link will show you the secret: It can only be viewed once and will then be removed from the database. -<% if @secret.expire_at.present? %> +<% if @secret.expire_at? %> It will also expire and be removed if not accessed before <%= @secret.expire_at.strftime('%d %B %Y') %>. <% end %> diff --git a/app/views/secrets/show.html.erb b/app/views/secrets/show.html.erb index df6302f..b59ceb4 100644 --- a/app/views/secrets/show.html.erb +++ b/app/views/secrets/show.html.erb @@ -13,14 +13,14 @@ It will be deleted from our system once you view it, so be sure to make a copy.

- <% if @secret.title.present? %> + <% if @secret.title? %>

Title: <%= @secret.title %>

<% end %> - <% if @secret.comments.present? %> + <% if @secret.comments? %>

Comments:

@@ -33,7 +33,7 @@

<% if @unencrypted_secret || flash.now[:error] %>

<%= @unencrypted_secret %>
- <% elsif @secret.encrypted_secret.blank? %> + <% elsif !@secret.encrypted_secret? %>
Secret has already been displayed and deleted.
<% else %> <%= form_tag '/decrypt_secret' do |f| %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 8f1758c..4631a2b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -2,6 +2,15 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Bullet Configuration + config.after_initialize do + Bullet.enable = true + Bullet.alert = true + Bullet.bullet_logger = true + Bullet.console = true + Bullet.rails_logger = true + end + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. @@ -73,4 +82,7 @@ # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # config.hosts << '0fe9-103-181-226-39.ngrok-free.app' + config.hosts.clear + end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 10d89b3..34d8794 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -27,7 +27,7 @@ config.assets.configure do |env| env.js_compressor = :uglifier # or :closure, :yui env.css_compressor = :sass # or :yui - end + end # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. diff --git a/config/environments/test.rb b/config/environments/test.rb index 031a469..f653209 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -56,4 +56,9 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + if defined?(Bullet) + Bullet.enable = true + Bullet.bullet_logger = true + Bullet.raise = true # Raises an error when N+1 queries are detected + end end diff --git a/config/puma.rb b/config/puma.rb index a248513..73217ff 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -24,11 +24,11 @@ # Any libraries that use a connection pool or another resource pool should # be configured to provide at least as many connections as the number of # threads. This includes Active Record's `pool` parameter in `database.yml`. -threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 3 } threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT", 3000) +port ENV.fetch("PORT") { 3000 } # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb index 1bbef90..496e4da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Rails.application.routes.draw do resources :auth_tokens, only: [:show, :new, :create] - resources :secrets, only: [:show, :new, :create, :edit, :update] + resources :secrets, only: [:show, :new, :create] resources :decrypted_secrets, only: :create post '/decrypt_secret', to: 'decrypted_secrets#create' diff --git a/docs/memory_profile_report.md b/docs/memory_profile_report.md new file mode 100644 index 0000000..64de23c --- /dev/null +++ b/docs/memory_profile_report.md @@ -0,0 +1,320 @@ +### Memory Profiling Report + +Memory Profiling was executed using `derailed_benchmarks` gem. + +Gem load profiling report + +``` +TOP: 146.3906 MiB + rails/all: 61.3281 MiB + action_mailbox/engine: 33.3438 MiB + action_mailbox: 33.3281 MiB + action_mailbox/mail_ext: 33.2656 MiB + action_mailbox/mail_ext/address_equality.rb: 30.2344 MiB + mail/elements/address: 30.2344 MiB + mail/parsers/address_lists_parser: 30.2188 MiB + mail: 3.0313 MiB + mail/field: 1.5313 MiB + mail/fields/resent_bcc_field: 1.2656 MiB + net/smtp: 0.4531 MiB + net/protocol: 0.3281 MiB (Also required by: net/http) + rails: 16.1406 MiB (Also required by: active_record/railtie, active_model/railtie, and 13 others) + rails/application: 14.9219 MiB + active_support/encrypted_configuration: 6.2344 MiB + active_support/encrypted_file: 6.1875 MiB + active_support/message_encryptor: 5.6563 MiB + active_support/messages/codec: 5.6094 MiB (Also required by: active_support/message_verifier) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-8.0.1/lib/active_support/messages/metadata: 5.6094 MiB + active_support/json: 5.6094 MiB + active_support/json/encoding: 5.3594 MiB + active_support/core_ext/object/json: 5.3438 MiB (Also required by: active_support/core_ext/object) + active_support/core_ext/time/conversions: 4.7813 MiB (Also required by: active_support/core_ext/date_time/conversions, active_support/core_ext/time/calculations) + active_support/values/time_zone: 4.75 MiB (Also required by: active_support/core_ext/date_time/conversions, active_support/time_with_zone) + tzinfo: 4.6719 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper: 2.8594 MiB + concurrent: 2.8594 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source, sprockets/manifest) + concurrent/configuration: 0.6406 MiB (Also required by: concurrent/scheduled_task, concurrent/options, and 3 others) + concurrent/delay: 0.4844 MiB (Also required by: concurrent/utility/processor_counter, concurrent) + concurrent/concern/obligation: 0.4375 MiB (Also required by: concurrent/ivar) + concurrent/atomic/event: 0.3125 MiB (Also required by: concurrent/executor/immediate_executor, concurrent/executor/ruby_thread_pool_executor, and 4 others) + concurrent/atomics: 0.5938 MiB + concurrent/atomic/reentrant_read_write_lock: 0.4531 MiB + concurrent/promises: 0.4688 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/tzinfo-2.0.6/lib/tzinfo/data_sources/posix_time_zone_parser: 1.2656 MiB + uri/generic: 0.4219 MiB (Also required by: global_id/uri/gid) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/uri-1.0.3/lib/uri/common: 0.3125 MiB (Also required by: uri) + tempfile: 0.5156 MiB (Also required by: rack/utils, /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-test-2.2.0/lib/rack/test/uploaded_file) + tmpdir: 0.4531 MiB (Also required by: execjs/external_runtime, /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/unicorn-6.1.0/lib/unicorn/tmpio) + active_support/key_generator: 6.0 MiB + openssl: 6.0 MiB (Also required by: active_support/message_encryptor, active_support/message_verifier, and 8 others) + openssl.so: 2.7813 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/openssl/ssl: 2.7031 MiB + ipaddr: 0.7969 MiB (Also required by: active_support/core_ext/object/json, ssrf_filter/ssrf_filter, and 2 others) + socket: 0.5313 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/openssl/ssl, net/protocol, and 9 others) + active_support/deprecation: 1.0156 MiB (Also required by: active_support/rails, active_record/errors) + active_support/deprecation/behaviors: 0.6094 MiB + active_support/notifications: 0.5469 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-8.0.1/lib/active_support/messages/serializer_with_fallback, active_support/subscriber) + active_support/notifications/fanout: 0.3906 MiB + yaml: 0.8438 MiB (Also required by: active_support/encrypted_configuration, active_record, and 10 others) + psych: 0.8438 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/psych-5.2.3/lib/psych/visitors: 0.3906 MiB + rails/engine: 0.5313 MiB + active_support: 0.875 MiB (Also required by: active_support/railtie, active_support/i18n_railtie, and 17 others) + active_support/dependencies/autoload: 0.5313 MiB (Also required by: web_console) + active_support/inflector/methods: 0.5313 MiB (Also required by: active_support/core_ext/time/conversions, active_support/core_ext/date_time/conversions, and 5 others) + active_support/inflections: 0.5156 MiB (Also required by: active_support/inflector) + active_support/inflector/inflections: 0.4531 MiB (Also required by: active_support/inflector) + active_support/i18n: 0.4219 MiB (Also required by: active_support/inflector/transliterate, abstract_controller) + i18n: 0.375 MiB + active_record/railtie: 4.9844 MiB (Also required by: active_storage/engine, action_mailbox/engine) + active_record: 2.5 MiB (Also required by: active_storage) + arel: 0.7813 MiB + arel/nodes: 0.3125 MiB + active_record/errors: 0.4688 MiB + active_model/errors: 0.3125 MiB + active_record/migration: 0.4063 MiB + action_controller/railtie: 2.4063 MiB (Also required by: active_storage/engine, rails/all, and 3 others) + action_controller: 1.4063 MiB + action_controller/metal/strong_parameters: 1.2656 MiB + rack/test: 0.8438 MiB + uri: 0.3281 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-test-2.2.0/lib/rack/test/cookie_jar, rack/utils, and 22 others) + action_view/railtie: 0.9375 MiB (Also required by: rails/all) + action_dispatch/routing/route_set: 0.5625 MiB + action_dispatch/journey: 0.375 MiB + active_storage/engine: 2.3125 MiB (Also required by: action_mailbox/engine, action_text/engine) + active_storage: 1.3438 MiB + marcel: 1.2188 MiB (Also required by: carrierwave/sanitized_file) + marcel/magic: 1.2188 MiB + marcel/tables: 1.125 MiB + active_job/railtie: 0.7813 MiB (Also required by: action_mailer/railtie, rails/all) + global_id/railtie: 0.6563 MiB + active_support/core_ext/integer/time: 0.5 MiB + active_support/core_ext/numeric/time: 0.375 MiB (Also required by: active_storage, action_mailbox) + active_support/core_ext/time/calculations: 0.375 MiB (Also required by: active_support/file_update_checker) + action_text/engine: 2.1719 MiB + action_text: 2.1719 MiB + nokogiri: 2.1406 MiB (Also required by: loofah, TOP) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/extension: 0.4844 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/version/info) + nokogiri/nokogiri: 0.4844 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/encoding_handler: 0.4688 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/xml: 0.4063 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/html4: 0.3906 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.18.3/lib/nokogiri/html) + rails/test_unit/railtie: 1.9063 MiB + rails/test_unit/line_filtering: 1.9063 MiB + rails/test_unit/runner: 1.9063 MiB + rails/test_unit/test_parser: 1.0156 MiB + ripper: 0.9844 MiB (Also required by: rails/source_annotation_extractor) + ripper/sexp: 0.5 MiB + rake/file_list: 0.7656 MiB + action_cable/engine: 0.4531 MiB + action_cable: 0.3594 MiB + rubocop: 25.0469 MiB (Also required by: rubocop-performance, rubocop-rails) + rubocop-ast: 10.0 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast: 10.0 MiB + parser: 9.0781 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parser-3.3.7.1/lib/parser/lexer-F1: 8.4375 MiB + regexp_parser: 1.5469 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/parser: 0.6563 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/expression: 0.5 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/scanner: 0.5469 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/options: 0.4063 MiB + optparse: 0.3281 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/cop/commissioner: 0.375 MiB + better_errors: 19.7031 MiB + better_errors/code_formatter: 19.0 MiB + better_errors/code_formatter/html: 18.9844 MiB + rouge: 18.9688 MiB (Also required by: better_errors/error_page) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/openedge.rb: 0.7813 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/irb.rb: 0.5781 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb: 0.5313 MiB (Also required by: rouge) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/crystal.rb: 0.5469 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/plsql.rb: 0.5 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb: 0.4219 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/irb.rb) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bsl.rb: 0.3594 MiB + rubocop-rails: 12.4375 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails_cops: 10.2188 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to: 0.625 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/index_by: 0.3594 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.15.2/lib/rubocop/rails: 0.3906 MiB + sassc-rails: 5.1406 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-rails-2.1.2/lib/sassc/rails: 5.1406 MiB + sassc: 2.5156 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0/lib/sassc/native: 2.1719 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-rails-2.1.2/lib/sassc/rails/railtie: 1.6094 MiB + sprockets/railtie: 1.5781 MiB + sprockets: 1.0469 MiB (Also required by: sprockets/rails/context, sprockets/rails/helper) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-rails-2.1.2/lib/sassc/rails/importer: 0.4688 MiB + tilt: 0.4063 MiB + rubocop-performance: 4.8906 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-performance-1.19.1/lib/rubocop/cop/performance_cops: 2.1719 MiB + omniauth-google-oauth2: 3.75 MiB + omniauth/google_oauth2: 3.75 MiB + omniauth/strategies/google_oauth2: 3.75 MiB + oauth2: 2.9063 MiB (Also required by: omniauth/strategies/oauth2) + oauth2/client: 2.1719 MiB + faraday: 2.0625 MiB + faraday/response: 0.5781 MiB + faraday/response/logger: 0.4844 MiB + faraday/logging/formatter: 0.3906 MiB + pp: 0.3281 MiB (Also required by: better_errors) + snaky_hash: 0.3906 MiB + omniauth/strategies/oauth2: 0.3906 MiB + jwt: 0.3594 MiB (Also required by: oauth2/strategy/assertion) + skylight: 2.5781 MiB (Also required by: skylight/railtie) + skylight/config: 1.5156 MiB + skylight/util/deploy: 1.4375 MiB + skylight/native: 0.5781 MiB + simple_form: 2.375 MiB + simple_form/action_view_extensions/builder: 2.1406 MiB + action_view/helpers: 2.1406 MiB (Also required by: sprockets/rails/context) + action_view/helpers/sanitize_helper: 0.8125 MiB (Also required by: action_view/helpers/text_helper) + rails-html-sanitizer: 0.7969 MiB + loofah: 0.6406 MiB + carrierwave: 1.9063 MiB + carrierwave/uploader: 1.5781 MiB + carrierwave/uploader/configuration: 1.1875 MiB + carrierwave/downloader/base: 1.1875 MiB + addressable: 0.5625 MiB + addressable/uri: 0.4375 MiB (Also required by: addressable/template) + ssrf_filter: 0.5469 MiB + ssrf_filter/ssrf_filter: 0.5469 MiB + net/http: 0.4844 MiB (Also required by: recaptcha, skylight/util/http) + pg: 1.7656 MiB + pg_ext: 1.6406 MiB + bugsnag: 1.375 MiB + bugsnag/configuration: 0.4375 MiB + unicorn: 0.8125 MiB + jbuilder: 0.7969 MiB + jbuilder/railtie: 0.6406 MiB + jbuilder/jbuilder_template: 0.625 MiB + jbuilder/collection_renderer: 0.5313 MiB + action_view/renderer/collection_renderer: 0.4844 MiB + action_view/renderer/partial_renderer: 0.4688 MiB + simplecov: 0.6406 MiB + listen: 0.4063 MiB (Also required by: spring/watcher/listen) + listen/listener: 0.4063 MiB +``` + +With files in app. + +Output for the report of: `RAILS_ENV=development bundle exec derailed exec mem` + +``` +Booting: development +Database 'topsekrit_development' already exists +Database 'topsekrit_test' already exists +Method: GET +Endpoint: "/" +## Impact of `require ` on RAM + +Showing all `require ` calls that consume 0.3 MiB or more of RSS +Configure with `CUT_OFF=0` for all entries or `CUT_OFF=5` for few entries +Note: Files only count against RAM on their first load. + If multiple libraries require the same file, then + the 'cost' only shows up under the first library + +TOP: 95.3906 MiB + application: 71.7344 MiB + rubocop: 26.0156 MiB (Also required by: rubocop-performance, rubocop-rails) + rubocop-ast: 7.25 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast: 7.25 MiB + parser: 6.6094 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parser-3.3.7.1/lib/parser/lexer-F1: 3.0156 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parser-3.3.7.1/lib/parser/lexer-strings: 2.7656 MiB + regexp_parser: 1.4219 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/parser: 0.7188 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/expression: 0.5625 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/regexp_parser-2.10.0/lib/regexp_parser/scanner: 0.375 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/cop/style/zero_length_predicate: 0.5 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/runner: 0.4844 MiB + parallel: 0.3281 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/cop/style/redundant_sort: 0.3906 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/config: 0.3594 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/cop/style/redundant_parentheses: 0.3125 MiB + better_errors: 18.1406 MiB + better_errors/code_formatter: 17.6563 MiB + better_errors/code_formatter/html: 17.6563 MiB + rouge: 17.6563 MiB (Also required by: better_errors/error_page) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/irb.rb: 0.6406 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb: 0.5313 MiB (Also required by: rouge) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/crystal.rb: 0.4531 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/igorpro.rb: 0.4531 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/ruby.rb: 0.4063 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/irb.rb) + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rouge-4.3.0/lib/rouge/lexers/bsl.rb: 0.3594 MiB + sassc-rails: 4.7656 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-rails-2.1.2/lib/sassc/rails: 4.7656 MiB + sassc: 2.3594 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0/lib/sassc/native: 2.25 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-rails-2.1.2/lib/sassc/rails/railtie: 1.9063 MiB + sprockets/railtie: 1.9063 MiB + sprockets: 1.6719 MiB (Also required by: sprockets/rails/context, sprockets/rails/helper) + sprockets/environment: 0.5313 MiB + sprockets/base: 0.5313 MiB (Also required by: sprockets/cached_environment) + omniauth-google-oauth2: 2.875 MiB + omniauth/google_oauth2: 2.875 MiB + omniauth/strategies/google_oauth2: 2.875 MiB + oauth2: 1.5938 MiB (Also required by: omniauth/strategies/oauth2) + oauth2/client: 0.8906 MiB + faraday: 0.7656 MiB + snaky_hash: 0.5469 MiB + jwt: 0.9531 MiB (Also required by: oauth2/strategy/assertion) + jwt/jwk: 0.3438 MiB + jwt/encode: 0.3438 MiB + rubocop-rails: 2.625 MiB + /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails_cops: 2.0156 MiB + carrierwave: 2.4688 MiB + carrierwave/uploader: 2.1406 MiB + carrierwave/uploader/configuration: 1.7031 MiB + carrierwave/downloader/base: 1.6875 MiB + ssrf_filter: 1.0 MiB + ssrf_filter/ssrf_filter: 1.0 MiB + net/http: 0.9375 MiB (Also required by: recaptcha, skylight/util/http) + resolv: 0.5938 MiB (Also required by: ssrf_filter/ssrf_filter, /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.31.0/lib/rubocop/cop/style/ip_addresses) + addressable: 0.6719 MiB + addressable/uri: 0.5938 MiB (Also required by: addressable/template) + simple_form: 2.375 MiB + simple_form/action_view_extensions/builder: 1.8438 MiB + action_view/helpers: 1.8438 MiB (Also required by: sprockets/rails/context, action_view/base) + action_view/helpers/tag_helper: 0.4219 MiB (Also required by: action_view/helpers/url_helper, action_view/helpers/text_helper, and 4 others) + action_view/helpers/sanitize_helper: 0.375 MiB (Also required by: action_view/helpers/text_helper) + rails-html-sanitizer: 0.375 MiB (Also required by: /Users/sumanawal/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actiontext-8.0.1/app/helpers/action_text/content_helper.rb) + loofah: 0.3438 MiB + rubocop-performance: 2.3281 MiB + pg: 1.9375 MiB (Also required by: active_record/connection_adapters/postgresql_adapter) + pg_ext: 1.6563 MiB + skylight: 1.5156 MiB (Also required by: skylight/railtie) + skylight/native: 0.5938 MiB + jbuilder: 1.1875 MiB + jbuilder/railtie: 1.1094 MiB + jbuilder/jbuilder_template: 1.1094 MiB + jbuilder/collection_renderer: 0.875 MiB + action_view/renderer/collection_renderer: 0.8594 MiB + action_view/renderer/partial_renderer: 0.8281 MiB + active_support/cache: 0.5625 MiB (Also required by: jbuilder/jbuilder_template) + okcomputer: 0.7969 MiB + unicorn: 0.6875 MiB + uglifier: 0.5938 MiB + execjs: 0.4531 MiB + execjs/runtimes: 0.4531 MiB + simplecov: 0.5781 MiB + bugsnag: 0.5469 MiB + logstasher: 0.4219 MiB + listen: 0.4063 MiB (Also required by: spring/watcher/listen, active_support/evented_file_update_checker) + listen/listener: 0.4063 MiB + puma: 0.375 MiB + active_record/base: 8.1406 MiB + active_record/connection_adapters/postgresql_adapter: 4.7969 MiB + active_record/connection_adapters/postgresql/schema_statements: 3.1406 MiB + active_record/connection_adapters/abstract_adapter: 0.5625 MiB + active_record/connection_adapters/postgresql/schema_definitions: 0.3438 MiB + active_record/connection_adapters/postgresql/oid: 0.3281 MiB + active_record/querying: 0.4219 MiB + active_record/enum: 0.3438 MiB + active_record/type: 0.3438 MiB + action_controller/base: 0.8906 MiB + action_dispatch/routing/mapper: 0.75 MiB + active_record/relation: 0.5313 MiB + web_console/request: 0.5156 MiB + action_dispatch/http/request: 0.4531 MiB + simple_form/form_builder: 0.4219 MiB + ``` diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9bdfafe..68e8e2c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -53,5 +53,15 @@ # Add commands to the rspec DSL for manipulating cookies config.include ShowMeTheCookies, :type => :feature + if defined?(Bullet) + config.before(:each) do + Bullet.start_request + end + + config.after(:each) do + Bullet.end_request + end + end + end diff --git a/spec/services/auth_token_service_spec.rb b/spec/services/auth_token_service_spec.rb index 563e4f5..3760141 100644 --- a/spec/services/auth_token_service_spec.rb +++ b/spec/services/auth_token_service_spec.rb @@ -28,7 +28,8 @@ it "does not tell the auth_token to notify" do expect_any_instance_of(AuthToken).to_not receive(:notify) - AuthTokenService.generate(params.merge!(email: '')) + params[:email] = '' + AuthTokenService.generate(params) end end