From b646626c58f1ee590b161693e10d54ea080d8a3c Mon Sep 17 00:00:00 2001 From: Gregg P <117232882+GcioGregg@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:16:53 -0700 Subject: [PATCH] Vfep 1534 rails7134 assume_ssl is true (#1168) * rails upgrade override origin * assume_ssl=true * cosmetic change to force jenkins * cosmetic change to force jenkins --------- Co-authored-by: nfstern02 --- Gemfile | 4 +- Gemfile.lock | 166 ++++++++++-------- config/application.rb | 12 +- config/environments/development.rb | 3 + config/environments/production.rb | 15 +- config/environments/test.rb | 9 +- .../initializers/filter_parameter_logging.rb | 2 +- spec/models/search_geocoder_spec.rb | 7 +- spec/rails_helper.rb | 3 + 9 files changed, 141 insertions(+), 80 deletions(-) diff --git a/Gemfile b/Gemfile index 08323d00f..1f9eef21a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '7.0.8.1' +gem 'rails', '7.1.3.4' gem 'active_model_serializers', '~> 0.10.14' # JSON API gem 'activerecord-import' # Mass importing of CSV data @@ -42,7 +42,7 @@ gem 'sentry-raven', '~> 3.1.2' gem 'sitemap_generator' gem 'sprockets-rails' # Rails 7 upgrade - needed for now. gem 'strong_migrations' -gem 'uglifier', '>= 1.3.0' +gem 'terser' gem 'vets_json_schema', git: 'https://github.com/department-of-veterans-affairs/vets-json-schema', branch: 'master' gem 'virtus', '~> 2.0.0' gem 'will_paginate' diff --git a/Gemfile.lock b/Gemfile.lock index 326d2ca8c..fd4d2c526 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,64 +18,69 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.1) - actionpack (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.1) - actionview (= 7.0.8.1) - activesupport (= 7.0.8.1) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.1) - actionpack (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.1) - activesupport (= 7.0.8.1) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_model_serializers (0.10.14) actionpack (>= 4.1) activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.0.8.1) - activesupport (= 7.0.8.1) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.0.8.1) - activesupport (= 7.0.8.1) - activerecord (7.0.8.1) - activemodel (= 7.0.8.1) - activesupport (= 7.0.8.1) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) activerecord-import (1.6.0) activerecord (>= 4.2) activerecord-session_store (2.1.0) @@ -85,17 +90,21 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 2.0.8, < 4) railties (>= 6.1) - activestorage (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activesupport (= 7.0.8.1) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.1) + activesupport (7.1.3.4) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) @@ -136,6 +145,7 @@ GEM concurrent-ruby (1.3.1) config (5.4.0) deep_merge (~> 1.2, >= 1.2.1) + connection_pool (2.4.1) crass (1.0.6) csv (3.3.0) database_cleaner (2.0.2) @@ -225,6 +235,10 @@ GEM i18n (1.14.5) concurrent-ruby (~> 1.0) ice_nine (0.11.2) + io-console (0.7.2) + irb (1.13.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -300,29 +314,36 @@ GEM method_source (~> 1.0) pry-nav (1.0.0) pry (>= 0.9.10, < 0.15) + psych (5.1.2) + stringio public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) - rack (2.2.9) + rack (3.0.11) rack-cors (2.0.2) rack (>= 2.0.0) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.1) - actioncable (= 7.0.8.1) - actionmailbox (= 7.0.8.1) - actionmailer (= 7.0.8.1) - actionpack (= 7.0.8.1) - actiontext (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activemodel (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.0.8.1) + railties (= 7.1.3.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -334,19 +355,24 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) - method_source + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) @@ -462,19 +488,20 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + stringio (3.1.1) strong_migrations (1.8.0) activerecord (>= 5.2) strscan (3.1.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) + terser (1.2.3) + execjs (>= 0.3.0, < 3) thor (1.3.1) thread_safe (0.3.6) tilt (2.1.0) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) unicode-display_width (2.5.0) vcr (6.2.0) virtus (2.0.0) @@ -491,6 +518,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) + webrick (1.8.1) websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -548,7 +576,7 @@ DEPENDENCIES puma (~> 6.4.2) rack (>= 2.2.8.1) rack-cors - rails (= 7.0.8.1) + rails (= 7.1.3.4) rails-controller-testing rails-html-sanitizer (>= 1.4.4) rainbow @@ -569,7 +597,7 @@ DEPENDENCIES spring sprockets-rails strong_migrations - uglifier (>= 1.3.0) + terser vcr (~> 6.2) vets_json_schema! virtus (~> 2.0.0) diff --git a/config/application.rb b/config/application.rb index d274f705c..7092bfd99 100755 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' @@ -10,6 +10,11 @@ module GibctDataService class Application < Rails::Application config.load_defaults '7.0' # enables zeitwerk mode in CRuby + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w(assets tasks)) + # Configuration for the application, engines, and railties goes here. # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. @@ -21,7 +26,7 @@ class Application < Rails::Application config.middleware.insert_before 0, Rack::Cors, logger: (-> { Rails.logger }) do allow do origins 'localhost:3001', 'localhost:3000', 'localhost' - resource '/v0/*', headers: :any, methods: :any, credentials: true + resource '/v0/*', headers: :any, methods: :any, credentials: true end end @@ -42,6 +47,7 @@ class Application < Rails::Application # Rails 7 upgrade - turn off warnings # https://stackoverflow.com/questions/76347365/how-do-i-set-legacy-connection-handling-to-false-in-my-rails-application - config.active_record.legacy_connection_handling = false + # the legacy_connection_handling configuration option, which was deprecated in Rails 7.0 and removed in Rails 7.1 + # config.active_record.legacy_connection_handling = false end end diff --git a/config/environments/development.rb b/config/environments/development.rb index a751b93a3..59dfb9cac 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -82,4 +82,7 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 7a881088e..67422492b 100755 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,8 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + # this is the newer, best practice in Rails 7.1.3 + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -27,7 +28,7 @@ # Compress JavaScripts and CSS. # Do we want to switch to the Terser gem? # https://stackoverflow.com/questions/75315372/when-running-rake-assetsprecompile-rails-env-production-over-es6-syntax-pipelin - config.assets.js_compressor = Uglifier.new(harmony: true) + config.assets.js_compressor = :terser # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. @@ -63,6 +64,14 @@ # We terminate SSL before traffic gets to the gi data service elb and traffic from the elb to the service is over http. So forcing ssl will break our ELB health checks. # config.force_ssl = true + # https://guides.rubyonrails.org/configuring.html#config-assume-ssl + # Makes application believe that all requests are arriving over SSL. This is useful when proxying + # through a load balancer that terminates SSL, the forwarded request will appear as though it's HTTP + # instead of HTTPS to the application. This makes redirects and cookie security target HTTP instead + # of HTTPS. This middleware makes the server assume that the proxy already terminated SSL, and that + # the request really is HTTPS. + config.assume_ssl=true + # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :info @@ -77,6 +86,8 @@ # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "gibct_data_service_production" + config.action_mailer.perform_caching = false + # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/test.rb b/config/environments/test.rb index f5510ab2a..1da41f2ec 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,6 +13,10 @@ # system, or in some way before deploying your code. config.eager_load = ENV["CI"].present? + # only solution found to solve database_cleaner errors after upgrade to Rails 7.1.3 (from 7.0.8) + # per nblezer comment in https://github.com/rspec/rspec-rails/issues/2697 + config.active_job.queue_adapter = :test + # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } @@ -55,5 +59,8 @@ # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = trueend + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c0907a564..76e92e43c 100755 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,4 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn] +Rails.application.config.filter_parameters += [:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn] diff --git a/spec/models/search_geocoder_spec.rb b/spec/models/search_geocoder_spec.rb index 176df3486..04017f4d0 100755 --- a/spec/models/search_geocoder_spec.rb +++ b/spec/models/search_geocoder_spec.rb @@ -200,8 +200,11 @@ build_and_create_institution :regular_address initial_progress_count = PreviewGenerationStatusInformation.count geo_search_results = described_class.new(version) - geo_search_results.process_geocoder_address - sleep(0.5) + + perform_enqueued_jobs do + geo_search_results.process_geocoder_address + end + expect(PreviewGenerationStatusInformation.count).to be > initial_progress_count end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index e27480444..380163ba4 100755 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -42,6 +42,9 @@ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures # config.fixture_path = "#{::Rails.root}/spec/fixtures" + # needed for perform_enqueued_jobs used in search_geocoder_spec + config.include ActiveJob::TestHelper + # Adding capybara DSL to rspec config.include Capybara::DSL config.include FixAll