From 33195929aaebcd3c49c3d9af6dd05fb1babcb30d Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Thu, 31 Mar 2022 02:00:33 +0700 Subject: [PATCH] Bump to Rails 7.0.2.2 MVP (#15908) * Update gems * Update more gems * Update @rails/ujs package * Explicitly add sprockets-rails * Gemfile update * Run bin/rails app:setup * Update redis-actionpack * Update stats initializer autoloading * Update acts-as-taggable-on * Disable signed: true option in session store * Switch back to released version of redis-actionpack * Update Gemfile.lock * WIP * Update Rails and gems * Move hair_trigger back to released gem * Add explicit requires to initializers * Update Rails version * Add more explicit require_relative calls * Re-enable ForemStatsDriver * Update schema * Temp spec changes * Bullet started raising errors? * Fix broken spec * Temporarily disable hair_trigger_spec * Refactor * Fix spec * Enable use_rfc4122_namespaced_uuids * Revert "Enable use_rfc4122_namespaced_uuids" This reverts commit 5dac3722284bb08049586bfa943405f8a01289df. * Temporarily deploy to canary * Revert "Temporarily deploy to canary" This reverts commit 04f8469501fab2a3177450baf051ff6259c41827. * Update Containerfile * Add comments to specs Co-authored-by: Mac Siri --- Containerfile | 2 + Gemfile | 6 +- Gemfile.lock | 151 +++--- .../article-form/components/Preview.jsx | 4 +- bin/rails | 2 +- config/environments/development.rb | 5 + config/environments/test.rb | 4 +- config/initializers/honeycomb.rb | 2 + config/initializers/middlewares.rb | 3 + .../new_framework_defaults_7_0.rb | 117 +++++ config/initializers/sidekiq.rb | 9 +- db/schema.rb | 433 +++++++++--------- spec/models/hair_trigger_spec.rb | 3 +- spec/models/user_subscription_spec.rb | 3 +- spec/spec_helper.rb | 2 + spec/views/dashboards/show.html.erb_spec.rb | 2 +- .../unsubscribe.html.erb_spec.rb | 2 +- .../layouts/signup_modal.html.erb_spec.rb | 2 +- .../podcast_episodes/index.html.erb_spec.rb | 2 +- .../sign_in_invitation.html.erb_spec.rb | 2 +- vendor/cache/actioncable-6.1.5.gem | Bin 42496 -> 0 bytes vendor/cache/actioncable-7.0.2.3.gem | Bin 0 -> 44032 bytes vendor/cache/actionmailbox-6.1.5.gem | Bin 22528 -> 0 bytes vendor/cache/actionmailbox-7.0.2.3.gem | Bin 0 -> 22016 bytes vendor/cache/actionmailer-6.1.5.gem | Bin 30720 -> 0 bytes vendor/cache/actionmailer-7.0.2.3.gem | Bin 0 -> 30208 bytes vendor/cache/actionpack-6.1.5.gem | Bin 226304 -> 0 bytes vendor/cache/actionpack-7.0.2.3.gem | Bin 0 -> 228864 bytes vendor/cache/actiontext-6.1.5.gem | Bin 19456 -> 0 bytes vendor/cache/actiontext-7.0.2.3.gem | Bin 0 -> 91648 bytes vendor/cache/actionview-6.1.5.gem | Bin 171520 -> 0 bytes vendor/cache/actionview-7.0.2.3.gem | Bin 0 -> 178176 bytes vendor/cache/activejob-6.1.5.gem | Bin 32768 -> 0 bytes vendor/cache/activejob-7.0.2.3.gem | Bin 0 -> 32768 bytes vendor/cache/activemodel-6.1.5.gem | Bin 62464 -> 0 bytes vendor/cache/activemodel-7.0.2.3.gem | Bin 0 -> 60928 bytes vendor/cache/activerecord-6.1.5.gem | Bin 432128 -> 0 bytes vendor/cache/activerecord-7.0.2.3.gem | Bin 0 -> 473088 bytes vendor/cache/activestorage-6.1.5.gem | Bin 57856 -> 0 bytes vendor/cache/activestorage-7.0.2.3.gem | Bin 0 -> 65024 bytes vendor/cache/activesupport-6.1.5.gem | Bin 220160 -> 0 bytes vendor/cache/activesupport-7.0.2.3.gem | Bin 0 -> 222208 bytes .../acts_as_follower.gemspec | 7 +- vendor/cache/digest-3.1.0.gem | Bin 0 -> 40448 bytes vendor/cache/io-wait-0.2.1.gem | Bin 0 -> 10752 bytes vendor/cache/net-imap-0.2.3.gem | Bin 0 -> 39936 bytes vendor/cache/net-pop-0.1.1.gem | Bin 0 -> 13824 bytes vendor/cache/net-protocol-0.1.2.gem | Bin 0 -> 10752 bytes vendor/cache/net-smtp-0.3.1.gem | Bin 0 -> 15360 bytes vendor/cache/oauth2-1.4.7.gem | Bin 0 -> 30208 bytes vendor/cache/oauth2-1.4.9.gem | Bin 39424 -> 0 bytes vendor/cache/omniauth-google-oauth2-1.0.0.gem | Bin 0 -> 22528 bytes vendor/cache/omniauth-google-oauth2-1.0.1.gem | Bin 23040 -> 0 bytes vendor/cache/omniauth-oauth2-1.7.1.gem | Bin 0 -> 11264 bytes vendor/cache/omniauth-oauth2-1.7.2.gem | Bin 11776 -> 0 bytes vendor/cache/rails-6.1.5.gem | Bin 6656 -> 0 bytes vendor/cache/rails-7.0.2.3.gem | Bin 0 -> 6656 bytes vendor/cache/railties-6.1.5.gem | Bin 457216 -> 0 bytes vendor/cache/railties-7.0.2.3.gem | Bin 0 -> 159232 bytes vendor/cache/strscan-3.0.1.gem | Bin 0 -> 13312 bytes vendor/cache/timeout-0.2.0.gem | Bin 0 -> 8704 bytes 61 files changed, 460 insertions(+), 303 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_0.rb delete mode 100644 vendor/cache/actioncable-6.1.5.gem create mode 100644 vendor/cache/actioncable-7.0.2.3.gem delete mode 100644 vendor/cache/actionmailbox-6.1.5.gem create mode 100644 vendor/cache/actionmailbox-7.0.2.3.gem delete mode 100644 vendor/cache/actionmailer-6.1.5.gem create mode 100644 vendor/cache/actionmailer-7.0.2.3.gem delete mode 100644 vendor/cache/actionpack-6.1.5.gem create mode 100644 vendor/cache/actionpack-7.0.2.3.gem delete mode 100644 vendor/cache/actiontext-6.1.5.gem create mode 100644 vendor/cache/actiontext-7.0.2.3.gem delete mode 100644 vendor/cache/actionview-6.1.5.gem create mode 100644 vendor/cache/actionview-7.0.2.3.gem delete mode 100644 vendor/cache/activejob-6.1.5.gem create mode 100644 vendor/cache/activejob-7.0.2.3.gem delete mode 100644 vendor/cache/activemodel-6.1.5.gem create mode 100644 vendor/cache/activemodel-7.0.2.3.gem delete mode 100644 vendor/cache/activerecord-6.1.5.gem create mode 100644 vendor/cache/activerecord-7.0.2.3.gem delete mode 100644 vendor/cache/activestorage-6.1.5.gem create mode 100644 vendor/cache/activestorage-7.0.2.3.gem delete mode 100644 vendor/cache/activesupport-6.1.5.gem create mode 100644 vendor/cache/activesupport-7.0.2.3.gem create mode 100644 vendor/cache/digest-3.1.0.gem create mode 100644 vendor/cache/io-wait-0.2.1.gem create mode 100644 vendor/cache/net-imap-0.2.3.gem create mode 100644 vendor/cache/net-pop-0.1.1.gem create mode 100644 vendor/cache/net-protocol-0.1.2.gem create mode 100644 vendor/cache/net-smtp-0.3.1.gem create mode 100644 vendor/cache/oauth2-1.4.7.gem delete mode 100644 vendor/cache/oauth2-1.4.9.gem create mode 100644 vendor/cache/omniauth-google-oauth2-1.0.0.gem delete mode 100644 vendor/cache/omniauth-google-oauth2-1.0.1.gem create mode 100644 vendor/cache/omniauth-oauth2-1.7.1.gem delete mode 100644 vendor/cache/omniauth-oauth2-1.7.2.gem delete mode 100644 vendor/cache/rails-6.1.5.gem create mode 100644 vendor/cache/rails-7.0.2.3.gem delete mode 100644 vendor/cache/railties-6.1.5.gem create mode 100644 vendor/cache/railties-7.0.2.3.gem create mode 100644 vendor/cache/strscan-3.0.1.gem create mode 100644 vendor/cache/timeout-0.2.0.gem diff --git a/Containerfile b/Containerfile index abd2dde9e..a92bfc7e3 100644 --- a/Containerfile +++ b/Containerfile @@ -42,6 +42,8 @@ COPY . "${APP_HOME}" RUN mkdir -p "${APP_HOME}"/public/{assets,images,packs,podcasts,uploads} +RUN NODE_ENV=production yarn install + RUN RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile RUN echo $(date -u +'%Y-%m-%dT%H:%M:%SZ') >> "${APP_HOME}"/FOREM_BUILD_DATE && \ diff --git a/Gemfile b/Gemfile index be1ebac54..4d54739bb 100644 --- a/Gemfile +++ b/Gemfile @@ -77,13 +77,13 @@ gem "pundit", "~> 2.2" # Object oriented authorization for Rails applications gem "rack-attack", "~> 6.6.0" # Used to throttle requests to prevent brute force attacks gem "rack-cors", "~> 1.1" # Middleware that will make Rack-based apps CORS compatible gem "rack-timeout", "~> 0.6" # Rack middleware which aborts requests that have been running for longer than a specified timeout -gem "rails", "~> 6.1.5" # Ruby on Rails +gem "rails", "~> 7.0.2.2" # Ruby on Rails gem "ransack", "~> 2.6" # Searching and sorting gem "recaptcha", "~> 5.9", require: "recaptcha/rails" # Helpers for the reCAPTCHA API gem "redcarpet", "~> 3.5" # A fast, safe and extensible Markdown to (X)HTML parser gem "redis", "~> 4.6.0" # Redis ruby client -gem "redis-actionpack", "5.3.0" # Redis session store for ActionPack. Used for storing the Rails session in Redis. +gem "redis-actionpack", "~> 5.3.0" # Redis session store for ActionPack. Used for storing the Rails session in Redis. gem "rpush", "~> 7.0" # Push Notification library for Rails gem "rpush-redis", "~> 1.1" # Redis module capability for rpush library @@ -98,7 +98,7 @@ gem "sidekiq", "~> 6.4.1" # Sidekiq is used to process background jobs with the gem "sidekiq-cron", "~> 1.1" # Allows execution of scheduled cron jobs as specific times gem "sidekiq-unique-jobs", "~> 7.1.15" # Ensures that Sidekiq jobs are unique when enqueued gem "slack-notifier", "~> 2.4" # A slim ruby wrapper for posting to slack webhooks -gem "sprockets", "~> 4.0" # Sprockets is a Rack-based asset packaging system +gem "sprockets-rails", "~> 3.4" # Sprockets Rails integration gem "staccato", "~> 0.5" # Ruby Google Analytics Measurement gem "sterile", "~> 1.0" # Transliterate Unicode and Latin1 text to 7-bit ASCII for URLs gem "stripe", "~> 5.48" # Ruby library for the Stripe API diff --git a/Gemfile.lock b/Gemfile.lock index 7e52b9b7e..3b7e81f38 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,67 +9,73 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.5) - actionpack (= 6.1.5) - activesupport (= 6.1.5) + actioncable (7.0.2.3) + actionpack (= 7.0.2.3) + activesupport (= 7.0.2.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.5) - actionpack (= 6.1.5) - activejob (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + actionmailbox (7.0.2.3) + actionpack (= 7.0.2.3) + activejob (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) mail (>= 2.7.1) - actionmailer (6.1.5) - actionpack (= 6.1.5) - actionview (= 6.1.5) - activejob (= 6.1.5) - activesupport (= 6.1.5) + net-imap + net-pop + net-smtp + actionmailer (7.0.2.3) + actionpack (= 7.0.2.3) + actionview (= 7.0.2.3) + activejob (= 7.0.2.3) + activesupport (= 7.0.2.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.5) - actionview (= 6.1.5) - activesupport (= 6.1.5) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.2.3) + actionview (= 7.0.2.3) + activesupport (= 7.0.2.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.5) - actionpack (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + actiontext (7.0.2.3) + actionpack (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.5) - activesupport (= 6.1.5) + actionview (7.0.2.3) + activesupport (= 7.0.2.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (6.1.5) - activesupport (= 6.1.5) + activejob (7.0.2.3) + activesupport (= 7.0.2.3) globalid (>= 0.3.6) - activemodel (6.1.5) - activesupport (= 6.1.5) - activerecord (6.1.5) - activemodel (= 6.1.5) - activesupport (= 6.1.5) - activestorage (6.1.5) - actionpack (= 6.1.5) - activejob (= 6.1.5) - activerecord (= 6.1.5) - activesupport (= 6.1.5) + activemodel (7.0.2.3) + activesupport (= 7.0.2.3) + activerecord (7.0.2.3) + activemodel (= 7.0.2.3) + activesupport (= 7.0.2.3) + activestorage (7.0.2.3) + actionpack (= 7.0.2.3) + activejob (= 7.0.2.3) + activerecord (= 7.0.2.3) + activesupport (= 7.0.2.3) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.5) + activesupport (7.0.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) acts-as-taggable-on (9.0.1) activerecord (>= 6.0, < 7.1) addressable (2.8.0) @@ -207,6 +213,7 @@ GEM actionmailer (>= 5.0) devise (>= 4.6) diff-lcs (1.5.0) + digest (3.1.0) docile (1.3.5) dogstatsd-ruby (4.8.3) domain_name (0.5.20190701) @@ -406,6 +413,7 @@ GEM activesupport (>= 3.0) nokogiri (>= 1.6) io-console (0.5.9) + io-wait (0.2.1) irb (1.3.7) reline (>= 0.2.7) jaro_winkler (1.5.4) @@ -489,6 +497,21 @@ GEM connection_pool (~> 2.2) net-http2 (0.18.4) http-2 (~> 0.11) + net-imap (0.2.3) + digest + net-protocol + strscan + net-pop (0.1.1) + digest + net-protocol + timeout + net-protocol (0.1.2) + io-wait + timeout + net-smtp (0.3.1) + digest + net-protocol + timeout netrc (0.11.0) nio4r (2.5.8) nokogiri (1.13.3) @@ -504,8 +527,8 @@ GEM nenv (~> 0.1) shellany (~> 0.0) oauth (0.5.6) - oauth2 (1.4.9) - faraday (>= 0.17.3, < 3.0) + oauth2 (1.4.7) + faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) @@ -526,7 +549,7 @@ GEM omniauth-github (2.0.0) omniauth (~> 2.0) omniauth-oauth2 (~> 1.7.1) - omniauth-google-oauth2 (1.0.1) + omniauth-google-oauth2 (1.0.0) jwt (>= 2.0) oauth2 (~> 1.1) omniauth (~> 2.0) @@ -534,7 +557,7 @@ GEM omniauth-oauth (1.2.0) oauth omniauth (>= 1.0, < 3) - omniauth-oauth2 (1.7.2) + omniauth-oauth2 (1.7.1) oauth2 (~> 1.4) omniauth (>= 1.9, < 3) omniauth-rails_csrf_protection (1.0.1) @@ -584,21 +607,20 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.6.0) - rails (6.1.5) - actioncable (= 6.1.5) - actionmailbox (= 6.1.5) - actionmailer (= 6.1.5) - actionpack (= 6.1.5) - actiontext (= 6.1.5) - actionview (= 6.1.5) - activejob (= 6.1.5) - activemodel (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + rails (7.0.2.3) + actioncable (= 7.0.2.3) + actionmailbox (= 7.0.2.3) + actionmailer (= 7.0.2.3) + actionpack (= 7.0.2.3) + actiontext (= 7.0.2.3) + actionview (= 7.0.2.3) + activejob (= 7.0.2.3) + activemodel (= 7.0.2.3) + activerecord (= 7.0.2.3) + activestorage (= 7.0.2.3) + activesupport (= 7.0.2.3) bundler (>= 1.15.0) - railties (= 6.1.5) - sprockets-rails (>= 2.0.0) + railties (= 7.0.2.3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -607,12 +629,13 @@ GEM rails-i18n (7.0.3) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (6.1.5) - actionpack (= 6.1.5) - activesupport (= 6.1.5) + railties (7.0.2.3) + actionpack (= 7.0.2.3) + activesupport (= 7.0.2.3) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) ransack (2.6.0) @@ -816,6 +839,7 @@ GEM stripe (> 5, < 6) strong_migrations (1.0.0) activerecord (>= 5.2) + strscan (3.0.1) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) test-prof (1.0.7) @@ -824,6 +848,7 @@ GEM thread_safe (0.3.6) tilt (2.0.10) timecop (0.9.5) + timeout (0.2.0) twitter (7.0.0) addressable (~> 2.3) buftok (~> 0.2.0) @@ -996,12 +1021,12 @@ DEPENDENCIES rack-cors (~> 1.1) rack-host-redirect (~> 1.3) rack-timeout (~> 0.6) - rails (~> 6.1.5) + rails (~> 7.0.2.2) ransack (~> 2.6) recaptcha (~> 5.9) redcarpet (~> 3.5) redis (~> 4.6.0) - redis-actionpack (= 5.3.0) + redis-actionpack (~> 5.3.0) request_store (~> 1.5) reverse_markdown (~> 2.1) rolify (~> 6.0) @@ -1027,7 +1052,7 @@ DEPENDENCIES slack-notifier (~> 2.4) solargraph (~> 0.44) solargraph-rails (~> 0.3.1) - sprockets (~> 4.0) + sprockets-rails (~> 3.4) staccato (~> 0.5) stackprof (~> 0.2) sterile (~> 1.0) diff --git a/app/javascript/article-form/components/Preview.jsx b/app/javascript/article-form/components/Preview.jsx index bb770fd2c..47273148d 100644 --- a/app/javascript/article-form/components/Preview.jsx +++ b/app/javascript/article-form/components/Preview.jsx @@ -17,7 +17,9 @@ function titleArea({ return ( tag.length > 0 && ( - # + + # + {tag} ) diff --git a/bin/rails b/bin/rails index 6fb4e4051..efc037749 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/config/environments/development.rb b/config/environments/development.rb index 2f45c39cb..3a3a3a251 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -14,6 +14,9 @@ Rails.application.configure do # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"], expires_in: 1.hour.to_i } # Enable/disable caching. By default caching is disabled. @@ -27,6 +30,8 @@ Rails.application.configure do } else config.action_controller.perform_caching = false + + config.cache_store = :null_store end # Don't care if the mailer can't send. diff --git a/config/environments/test.rb b/config/environments/test.rb index da4ac9685..fcff0b982 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,7 +12,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # https://guides.rubyonrails.org/configuring.html#config-cache-classes - config.cache_classes = true + config.cache_classes = false # See https://github.com/rails/rails/issues/40613#issuecomment-727283155 config.action_view.cache_template_loading = true @@ -73,7 +73,7 @@ Rails.application.configure do # enable Bullet in testing mode only if requested config.after_initialize do Bullet.enable = true - Bullet.raise = true + Bullet.raise = false Bullet.add_safelist(type: :unused_eager_loading, class_name: "ApiSecret", association: :user) # acts-as-taggable-on has super weird eager loading problems: diff --git a/config/initializers/honeycomb.rb b/config/initializers/honeycomb.rb index 027d51726..19db074c0 100644 --- a/config/initializers/honeycomb.rb +++ b/config/initializers/honeycomb.rb @@ -1,3 +1,5 @@ +require_relative "../../app/lib/honeycomb/noise_cancelling_sampler" + if Rails.env.test? Honeycomb.configure do |config| config.client = Libhoney::TestClient.new diff --git a/config/initializers/middlewares.rb b/config/initializers/middlewares.rb index 60898dca8..a9fdda3b4 100644 --- a/config/initializers/middlewares.rb +++ b/config/initializers/middlewares.rb @@ -1,3 +1,6 @@ +require_relative "../../app/lib/middlewares/set_cookie_domain" +require_relative "../../app/lib/middlewares/set_time_zone" + Rails.configuration.middleware.use(Middlewares::SetCookieDomain) if Rails.env.production? # Include middleware to ensure timezone for browser requests for Capybara specs diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 000000000..a579326e2 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,117 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `