From 74bdda6ade1057864c1184b006591df0bbaff8a7 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 19 Jan 2023 17:03:53 +0330 Subject: [PATCH 01/14] Upgrate to 6.1.7.1 --- Gemfile | 2 +- Gemfile.lock | 125 ++++++++++++++++++++++++++------------------------- package.json | 2 +- yarn.lock | 8 ++-- 4 files changed, 70 insertions(+), 67 deletions(-) diff --git a/Gemfile b/Gemfile index b696123c..96b4ca95 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem "shakapacker", "6.5.5" # Bundle edge Rails instead: gem "rails", github: "rails/rails" gem "listen" -gem "rails", "~> 6.1.4" +gem "rails", "~> 6.1.7.1" gem "pg" diff --git a/Gemfile.lock b/Gemfile.lock index 0ed53bf9..b6e04d1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,60 +1,60 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + actioncable (6.1.7.1) + actionpack (= 6.1.7.1) + activesupport (= 6.1.7.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailbox (6.1.7.1) + actionpack (= 6.1.7.1) + activejob (= 6.1.7.1) + activerecord (= 6.1.7.1) + activestorage (= 6.1.7.1) + activesupport (= 6.1.7.1) mail (>= 2.7.1) - actionmailer (6.1.4.4) - actionpack (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailer (6.1.7.1) + actionpack (= 6.1.7.1) + actionview (= 6.1.7.1) + activejob (= 6.1.7.1) + activesupport (= 6.1.7.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.4) - actionview (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionpack (6.1.7.1) + actionview (= 6.1.7.1) + activesupport (= 6.1.7.1) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.4) - actionpack (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actiontext (6.1.7.1) + actionpack (= 6.1.7.1) + activerecord (= 6.1.7.1) + activestorage (= 6.1.7.1) + activesupport (= 6.1.7.1) nokogiri (>= 1.8.5) - actionview (6.1.4.4) - activesupport (= 6.1.4.4) + actionview (6.1.7.1) + activesupport (= 6.1.7.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.4) - activesupport (= 6.1.4.4) + activejob (6.1.7.1) + activesupport (= 6.1.7.1) globalid (>= 0.3.6) - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) - activestorage (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activesupport (= 6.1.4.4) - marcel (~> 1.0.0) + activemodel (6.1.7.1) + activesupport (= 6.1.7.1) + activerecord (6.1.7.1) + activemodel (= 6.1.7.1) + activesupport (= 6.1.7.1) + activestorage (6.1.7.1) + actionpack (= 6.1.7.1) + activejob (= 6.1.7.1) + activerecord (= 6.1.7.1) + activesupport (= 6.1.7.1) + marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.4) + activesupport (6.1.7.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -115,7 +115,7 @@ GEM erubi (1.10.0) erubis (2.7.0) execjs (2.8.1) - factory_bot (6.2.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) @@ -125,7 +125,7 @@ GEM generator_spec (0.9.4) activesupport (>= 3.0.0) railties (>= 3.0.0) - globalid (1.0.0) + globalid (1.0.1) activesupport (>= 5.0) i18n (1.8.11) concurrent-ruby (~> 1.0) @@ -142,8 +142,11 @@ GEM loofah (2.13.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.0.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) @@ -193,20 +196,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4.4) - actioncable (= 6.1.4.4) - actionmailbox (= 6.1.4.4) - actionmailer (= 6.1.4.4) - actionpack (= 6.1.4.4) - actiontext (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activemodel (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + rails (6.1.7.1) + actioncable (= 6.1.7.1) + actionmailbox (= 6.1.7.1) + actionmailer (= 6.1.7.1) + actionpack (= 6.1.7.1) + actiontext (= 6.1.7.1) + actionview (= 6.1.7.1) + activejob (= 6.1.7.1) + activemodel (= 6.1.7.1) + activerecord (= 6.1.7.1) + activestorage (= 6.1.7.1) + activesupport (= 6.1.7.1) bundler (>= 1.15.0) - railties (= 6.1.4.4) + railties (= 6.1.7.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -221,11 +224,11 @@ GEM json require_all (~> 3.0) ruby-progressbar - railties (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + railties (6.1.7.1) + actionpack (= 6.1.7.1) + activesupport (= 6.1.7.1) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) rainbow (3.0.0) rake (13.0.6) @@ -251,7 +254,7 @@ GEM rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-rails (5.0.2) + rspec-rails (5.1.2) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -274,7 +277,7 @@ GEM rubocop-performance (1.13.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.13.2) + rubocop-rails (2.15.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) @@ -387,7 +390,7 @@ DEPENDENCIES pry-rescue pry-stack_explorer puma - rails (~> 6.1.4) + rails (~> 6.1.7.1) rails-html-sanitizer rails_best_practices rainbow diff --git a/package.json b/package.json index dfa3c7df..ec3139f1 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@babel/plugin-transform-runtime": "^7.12.10", "@babel/preset-env": "^7.12.10", "@babel/preset-react": "^7.12.10", - "@rails/actioncable": "6.1.4-4", + "@rails/actioncable": "6.1.7-1", "autoprefixer": "^7.1.5", "axios": "^0.17.1", "babel-loader": "^8.2.3", diff --git a/yarn.lock b/yarn.lock index e562802a..b6192129 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1292,10 +1292,10 @@ schema-utils "^3.0.0" source-map "^0.7.3" -"@rails/actioncable@6.1.4-4": - version "6.1.4-4" - resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.1.4-4.tgz#5978ea03f2ec31ac46d9f63e8c1cb5a05f5002ac" - integrity sha512-EGRSboNF4M20LWUpabMfa/YswG+kw6a0xPZmd+ls4eIQS6pEeh1eoSYDyuyiLiTARXiA9PBFYk8+k4PiKHbN6w== +"@rails/actioncable@6.1.7-1": + version "6.1.7-1" + resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.1.7-1.tgz#ec0bfab2690eebc3887ad15ee4a9bc3811efdd62" + integrity sha512-pRyLNeVrH19FH0VOE9ZQ3+UrN11FFcboZoY43RzqrNhktdvXvTXegdPDip0/neK4RkBkaEpKomtQ/iTcQCR0Qg== "@trysound/sax@0.2.0": version "0.2.0" From 313904e5acbcbdf202ce4fc15239228750694104 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Wed, 18 Jan 2023 18:35:54 +0330 Subject: [PATCH 02/14] Fix rubocop I18nLocaleText issue --- app/controllers/comments_controller.rb | 6 +++--- config/locales/en.yml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 67151b0c..55ec89c7 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -28,7 +28,7 @@ def create respond_to do |format| if @comment.save - format.html { redirect_to @comment, notice: "Comment was successfully created." } + format.html { redirect_to @comment, notice: I18n.t("comment_was_successfully_created") } format.json { render :show, status: :created, location: @comment } else format.html { render :new } @@ -42,7 +42,7 @@ def create def update respond_to do |format| if @comment.update(comment_params) - format.html { redirect_to @comment, notice: "Comment was successfully updated." } + format.html { redirect_to @comment, notice: I18n.t("comment_was_successfully_updated") } format.json { render :show, status: :ok, location: @comment } else format.html { render :edit } @@ -56,7 +56,7 @@ def update def destroy @comment.destroy! respond_to do |format| - format.html { redirect_to comments_url, notice: "Comment was successfully destroyed." } + format.html { redirect_to comments_url, notice: I18n.t("comment_was_successfully_destroyed") } format.json { head :no_content } end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9ff110cc..a41df397 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,3 +21,6 @@ en: placeholder: "Say something using markdown..." saving: "Saving" post: "Post" + comment_was_successfully_created: "Comment was successfully created." + comment_was_successfully_updated: "Comment was successfully updated." + comment_was_successfully_destroyed: "Comment was successfully destroyed." From 9170481f57a1ca4f758fe393ffb5b5195a9ac975 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 19 Jan 2023 18:11:27 +0330 Subject: [PATCH 03/14] Apply Rails 6.1.7.1 file changes --- bin/setup | 3 +++ config/cable.yml | 2 +- config/initializers/assets.rb | 2 ++ .../initializers/content_security_policy.rb | 5 ++-- ..._to_active_storage_blobs.active_storage.rb | 22 +++++++++++++++ ..._storage_variant_records.active_storage.rb | 27 +++++++++++++++++++ db/schema.rb | 2 +- 7 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20230119143747_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20230119143748_create_active_storage_variant_records.active_storage.rb diff --git a/bin/setup b/bin/setup index 57923026..90700ac4 100755 --- a/bin/setup +++ b/bin/setup @@ -17,6 +17,9 @@ FileUtils.chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies + system! 'bin/yarn' + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' diff --git a/config/cable.yml b/config/cable.yml index 66e463e7..e108bb59 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,7 +1,7 @@ production: adapter: redis url: <%#= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - + channel_prefix: rails_react_tutorial_production development: adapter: redis diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 101a2902..ba194685 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -7,6 +7,8 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join("node_modules") # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f7fadc06..f3bcce54 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -6,15 +6,14 @@ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy # Rails.application.config.content_security_policy do |policy| -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - # policy.default_src :self, :https # policy.font_src :self, :https, :data # policy.img_src :self, :https, :data # policy.object_src :none # policy.script_src :self, :https # policy.style_src :self, :https +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? # # Specify URI for violation reports # # policy.report_uri "/csp-violation-report-endpoint" diff --git a/db/migrate/20230119143747_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20230119143747_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 00000000..a15c6ce8 --- /dev/null +++ b/db/migrate/20230119143747_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20230119143748_create_active_storage_variant_records.active_storage.rb b/db/migrate/20230119143748_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 00000000..94ac83af --- /dev/null +++ b/db/migrate/20230119143748_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/schema.rb b/db/schema.rb index dd4b2ab4..06eb7195 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_01_03_221124) do +ActiveRecord::Schema.define(version: 2023_01_19_143748) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 97ccad8c781efdcae1f1dd34d32b6273d6e9d506 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 19 Jan 2023 19:13:53 +0330 Subject: [PATCH 04/14] Upgrade to Rails 7 and update dependencies --- Gemfile | 2 +- Gemfile.lock | 270 ++++++++++++++++++++++++++------------------------- package.json | 2 +- yarn.lock | 8 +- 4 files changed, 146 insertions(+), 136 deletions(-) diff --git a/Gemfile b/Gemfile index 96b4ca95..bac163e2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem "shakapacker", "6.5.5" # Bundle edge Rails instead: gem "rails", github: "rails/rails" gem "listen" -gem "rails", "~> 6.1.7.1" +gem "rails", "~> 7.0" gem "pg" diff --git a/Gemfile.lock b/Gemfile.lock index b6e04d1a..9f6bc010 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,69 +1,75 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.1) - actionpack (= 6.1.7.1) - activesupport (= 6.1.7.1) + actioncable (7.0.4.1) + actionpack (= 7.0.4.1) + activesupport (= 7.0.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.1) - actionpack (= 6.1.7.1) - activejob (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + actionmailbox (7.0.4.1) + actionpack (= 7.0.4.1) + activejob (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) mail (>= 2.7.1) - actionmailer (6.1.7.1) - actionpack (= 6.1.7.1) - actionview (= 6.1.7.1) - activejob (= 6.1.7.1) - activesupport (= 6.1.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.1) + actionpack (= 7.0.4.1) + actionview (= 7.0.4.1) + activejob (= 7.0.4.1) + activesupport (= 7.0.4.1) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.1) - actionview (= 6.1.7.1) - activesupport (= 6.1.7.1) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4.1) + actionview (= 7.0.4.1) + activesupport (= 7.0.4.1) + 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.7.1) - actionpack (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + actiontext (7.0.4.1) + actionpack (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.1) - activesupport (= 6.1.7.1) + actionview (7.0.4.1) + activesupport (= 7.0.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.1) - activesupport (= 6.1.7.1) + activejob (7.0.4.1) + activesupport (= 7.0.4.1) globalid (>= 0.3.6) - activemodel (6.1.7.1) - activesupport (= 6.1.7.1) - activerecord (6.1.7.1) - activemodel (= 6.1.7.1) - activesupport (= 6.1.7.1) - activestorage (6.1.7.1) - actionpack (= 6.1.7.1) - activejob (= 6.1.7.1) - activerecord (= 6.1.7.1) - activesupport (= 6.1.7.1) + activemodel (7.0.4.1) + activesupport (= 7.0.4.1) + activerecord (7.0.4.1) + activemodel (= 7.0.4.1) + activesupport (= 7.0.4.1) + activestorage (7.0.4.1) + actionpack (= 7.0.4.1) + activejob (= 7.0.4.1) + activerecord (= 7.0.4.1) + activesupport (= 7.0.4.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.1) + activesupport (7.0.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - autoprefixer-rails (10.4.0.0) + autoprefixer-rails (10.4.7.0) execjs (~> 2) awesome_print (1.9.2) bindex (0.8.1) @@ -71,7 +77,7 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.4) byebug (11.1.3) - capybara (3.36.0) + capybara (3.38.0) addressable matrix mini_mime (>= 0.1.3) @@ -80,11 +86,11 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - capybara-screenshot (1.0.25) + capybara-screenshot (1.0.26) capybara (>= 1.0, < 4) launchy childprocess (3.0.0) - code_analyzer (0.5.2) + code_analyzer (0.5.5) sexp_processor coderay (1.1.3) coffee-rails (5.0.0) @@ -94,7 +100,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) connection_pool (2.3.0) coveralls_reborn (0.25.0) simplecov (>= 0.18.1, < 0.22.0) @@ -108,11 +114,11 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.2) + date (3.3.3) debug_inspector (1.1.0) diff-lcs (1.5.0) docile (1.4.0) - erubi (1.10.0) + erubi (1.12.0) erubis (2.7.0) execjs (2.8.1) factory_bot (6.2.1) @@ -120,26 +126,26 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - ffi (1.15.4) + ffi (1.15.5) foreman (0.87.2) generator_spec (0.9.4) activesupport (>= 3.0.0) railties (>= 3.0.0) globalid (1.0.1) activesupport (>= 5.0) - i18n (1.8.11) + i18n (1.12.0) concurrent-ruby (~> 1.0) interception (0.5) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.6.1) - launchy (2.5.0) - addressable (~> 2.7) - listen (3.7.0) + json (2.6.3) + launchy (2.5.2) + addressable (~> 2.8) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.13.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.8.0.1) @@ -152,31 +158,31 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.1) - minitest (5.15.0) - net-imap (0.3.2) + minitest (5.17.0) + net-imap (0.3.4) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.1.3) + net-protocol (0.2.1) timeout - net-smtp (0.3.2) + net-smtp (0.3.3) net-protocol nio4r (2.5.8) - nokogiri (1.13.10) + nokogiri (1.14.0) mini_portile2 (~> 2.8.0) racc (~> 1.4) - parallel (1.21.0) - parser (3.1.1.0) + parallel (1.22.1) + parser (3.2.0.0) ast (~> 2.4.1) - pg (1.2.3) - pry (0.14.1) + pg (1.4.5) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.8.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.10) - pry-doc (1.2.0) + pry (>= 0.13, < 0.15) + pry-doc (1.4.0) pry (~> 0.11) yard (~> 0.9.11) pry-rails (0.3.9) @@ -187,55 +193,58 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - public_suffix (4.0.6) - puma (5.5.2) + psych (5.0.2) + stringio + public_suffix (5.0.1) + puma (6.0.2) nio4r (~> 2.0) racc (1.6.2) - rack (2.2.3) - rack-proxy (0.7.4) + rack (2.2.6.2) + rack-proxy (0.7.6) rack - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.7.1) - actioncable (= 6.1.7.1) - actionmailbox (= 6.1.7.1) - actionmailer (= 6.1.7.1) - actionpack (= 6.1.7.1) - actiontext (= 6.1.7.1) - actionview (= 6.1.7.1) - activejob (= 6.1.7.1) - activemodel (= 6.1.7.1) - activerecord (= 6.1.7.1) - activestorage (= 6.1.7.1) - activesupport (= 6.1.7.1) + rack-test (2.0.2) + rack (>= 1.3) + rails (7.0.4.1) + actioncable (= 7.0.4.1) + actionmailbox (= 7.0.4.1) + actionmailer (= 7.0.4.1) + actionpack (= 7.0.4.1) + actiontext (= 7.0.4.1) + actionview (= 7.0.4.1) + activejob (= 7.0.4.1) + activemodel (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) bundler (>= 1.15.0) - railties (= 6.1.7.1) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - rails_best_practices (1.22.1) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + rails_best_practices (1.23.2) activesupport - code_analyzer (>= 0.5.2) + code_analyzer (~> 0.5.5) erubis i18n json require_all (~> 3.0) ruby-progressbar - railties (6.1.7.1) - actionpack (= 6.1.7.1) - activesupport (= 6.1.7.1) + railties (7.0.4.1) + actionpack (= 7.0.4.1) + activesupport (= 7.0.4.1) method_source rake (>= 12.2) thor (~> 1.0) - rainbow (3.0.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.0) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.3.3) + rdoc (6.5.0) + psych (>= 4.0.0) react_on_rails (13.2.0) addressable connection_pool @@ -243,26 +252,26 @@ GEM rails (>= 5.2) rainbow (~> 3.0) redis (3.3.3) - regexp_parser (2.2.0) + regexp_parser (2.6.1) require_all (3.0.0) rexml (3.2.5) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.10.3) + rspec-support (~> 3.12.0) + rspec-rails (6.0.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.11) + rspec-expectations (~> 3.11) + rspec-mocks (~> 3.11) + rspec-support (~> 3.11) + rspec-support (3.12.0) rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) @@ -272,16 +281,16 @@ GEM rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.16.0) + rubocop-ast (1.24.1) parser (>= 3.1.1.0) - rubocop-performance (1.13.2) + rubocop-performance (1.15.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.15.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.8.0) + rubocop-rspec (2.11.1) rubocop (~> 1.19) ruby-progressbar (1.11.0) rubyzip (1.3.0) @@ -302,13 +311,13 @@ GEM tilt scss_lint (0.59.0) sass (~> 3.5, >= 3.5.5) - sdoc (2.3.0) - rdoc (>= 5.0, < 6.4.0) + sdoc (2.6.0) + rdoc (>= 5.0) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) semantic_range (3.0.0) - sexp_processor (4.16.0) + sexp_processor (4.16.1) shakapacker (6.5.5) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -320,29 +329,30 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.0.0) + spring (4.1.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (4.0.2) + sprockets (4.2.0) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + stringio (3.0.4) sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) thor (1.2.1) - tilt (2.0.10) - timeout (0.3.0) - tins (1.31.1) + tilt (2.0.11) + timeout (0.3.1) + tins (1.32.1) sync - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.1.0) + unicode-display_width (2.4.2) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -358,9 +368,9 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.27) + yard (0.9.28) webrick (~> 1.7.0) - zeitwerk (2.5.3) + zeitwerk (2.6.6) PLATFORMS ruby @@ -390,7 +400,7 @@ DEPENDENCIES pry-rescue pry-stack_explorer puma - rails (~> 6.1.7.1) + rails (~> 7.0) rails-html-sanitizer rails_best_practices rainbow diff --git a/package.json b/package.json index ec3139f1..a1a2ea35 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@babel/plugin-transform-runtime": "^7.12.10", "@babel/preset-env": "^7.12.10", "@babel/preset-react": "^7.12.10", - "@rails/actioncable": "6.1.7-1", + "@rails/actioncable": "7.0.4-1", "autoprefixer": "^7.1.5", "axios": "^0.17.1", "babel-loader": "^8.2.3", diff --git a/yarn.lock b/yarn.lock index b6192129..7a22eb46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1292,10 +1292,10 @@ schema-utils "^3.0.0" source-map "^0.7.3" -"@rails/actioncable@6.1.7-1": - version "6.1.7-1" - resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.1.7-1.tgz#ec0bfab2690eebc3887ad15ee4a9bc3811efdd62" - integrity sha512-pRyLNeVrH19FH0VOE9ZQ3+UrN11FFcboZoY43RzqrNhktdvXvTXegdPDip0/neK4RkBkaEpKomtQ/iTcQCR0Qg== +"@rails/actioncable@7.0.4-1": + version "7.0.4-1" + resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.0.4-1.tgz#b3b9869ff5510860098db42decf8be034e0c29e0" + integrity sha512-uY02jap6xLuU/wS5FN1Fyvs2PT22Che7cvKUtQnYdR4WpteqbGrhOFBax3OfySoxIG5zOngMdSikZ2n2lACPLw== "@trysound/sax@0.2.0": version "0.2.0" From 23758478961543dd97baec37a72bb2fecf984f5e Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 19 Jan 2023 19:52:46 +0330 Subject: [PATCH 05/14] Apply Rails 7 file changes --- config/environments/development.rb | 3 + config/environments/test.rb | 8 +- config/initializers/assets.rb | 2 - .../initializers/content_security_policy.rb | 49 +++---- .../initializers/filter_parameter_logging.rb | 4 +- .../new_framework_defaults_7_0.rb | 135 ++++++++++++++++++ ...e_storage_blobs_checksum.active_storage.rb | 8 ++ db/schema.rb | 13 +- 8 files changed, 183 insertions(+), 39 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_0.rb create mode 100644 db/migrate/20230119162216_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index ac8d085d..a76b413e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,6 +16,9 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? diff --git a/config/environments/test.rb b/config/environments/test.rb index 86ff12e0..08426ee9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,11 +10,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + # config.eager_load = ENV["CI"].present? config.eager_load = false # Configure public file server for tests with Cache-Control for performance. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ba194685..101a2902 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -7,8 +7,6 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join("node_modules") # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f3bcce54..62a49ddd 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,31 +1,28 @@ # frozen_string_literal: true # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header -# Rails.application.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 3babc73f..3df77c5b 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -2,7 +2,9 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. Rails.application.config.filter_parameters += %i[ passw secret token _key crypt salt certificate otp ssn ] 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 00000000..4d580245 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,135 @@ +# 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 `