From f5fffe1c6029e4085cbf6eadcc070af3d4333f34 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:44:02 +0000 Subject: [PATCH 01/12] Add csv and ostruct gems to silence warnings --- Gemfile | 2 ++ Gemfile.lock | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c75d7bf9..99fbd177 100644 --- a/Gemfile +++ b/Gemfile @@ -7,12 +7,14 @@ gem "dotenv-rails", require: "dotenv/rails-now" gem "appsignal" gem "bootsnap", ">= 1.4.4", require: false +gem "csv", require: false gem "dartsass-rails" gem "faraday" gem "govuk_design_system_formbuilder" gem "httparty" gem "jsbundling-rails" gem "lograge", "~> 0.14.0" +gem "ostruct" gem "pg" gem "puma", ">= 5.3.1" gem "rails", "~> 7.2" diff --git a/Gemfile.lock b/Gemfile.lock index b973e6ad..daf0eb7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,6 +102,7 @@ GEM crack (0.4.5) rexml crass (1.0.6) + csv (3.2.8) dartsass-rails (0.5.1) railties (>= 6.0.0) sass-embedded (~> 1.63) @@ -177,7 +178,7 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.25.1) @@ -202,6 +203,7 @@ GEM racc (~> 1.4) nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) + ostruct (0.6.0) parallel (1.26.3) parser (3.3.4.2) ast (~> 2.4.1) @@ -388,6 +390,7 @@ DEPENDENCIES brakeman bundler-audit capybara + csv dartsass-rails dotenv-rails factory_bot_rails @@ -398,6 +401,7 @@ DEPENDENCIES jsbundling-rails listen (~> 3.3) lograge (~> 0.14.0) + ostruct pg pry-byebug puma (>= 5.3.1) From 5d7f62a0073c3348f6fcb646598205bdb30482d7 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:44:44 +0000 Subject: [PATCH 02/12] Fix dotenv deprecation warning Use dotenv/load instead of dotenv/rails-now. --- Gemfile | 2 +- Gemfile.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 99fbd177..ed01449c 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" # Load environment variables -gem "dotenv-rails", require: "dotenv/rails-now" +gem "dotenv-rails", require: "dotenv/load" gem "appsignal" gem "bootsnap", ">= 1.4.4", require: false diff --git a/Gemfile.lock b/Gemfile.lock index daf0eb7e..ceabc17b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,9 +108,9 @@ GEM sass-embedded (~> 1.63) date (3.3.4) diff-lcs (1.5.0) - dotenv (3.1.2) - dotenv-rails (3.1.2) - dotenv (= 3.1.2) + dotenv (3.1.4) + dotenv-rails (3.1.4) + dotenv (= 3.1.4) railties (>= 6.1) drb (2.2.1) erubi (1.13.0) @@ -151,7 +151,7 @@ GEM i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.14.0) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) jsbundling-rails (1.3.1) @@ -168,7 +168,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.22.0) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -270,7 +270,7 @@ GEM rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.9.2) - reline (0.5.9) + reline (0.5.10) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) @@ -352,7 +352,7 @@ GEM stimulus-rails (1.2.2) railties (>= 6.0.0) stringio (3.1.1) - thor (1.3.1) + thor (1.3.2) timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) @@ -377,7 +377,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.17) + zeitwerk (2.7.1) PLATFORMS aarch64-linux From 549114fe57c01be4a9eb6f2f8cb4ecedcc2b1ce1 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:46:20 +0000 Subject: [PATCH 03/12] Remove QuietLogger This is now handled by the lograge gem. --- config/application.rb | 4 ---- lib/quiet_logger.rb | 31 ------------------------------- 2 files changed, 35 deletions(-) delete mode 100644 lib/quiet_logger.rb diff --git a/config/application.rb b/config/application.rb index 01634de3..0a47fd0e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative "boot" -require_relative "../lib/quiet_logger" require "rails" # Pick the frameworks you want: @@ -45,9 +44,6 @@ class Application < Rails::Application config.action_controller.forgery_protection_origin_check = false - # Don't log certain requests that spam the log files - config.middleware.insert_before Rails::Rack::Logger, QuietLogger, paths: ["/healthcheck"] - config.os_vector_tiles_api_key = ENV["OS_VECTOR_TILES_API_KEY"] config.api_host = ENV.fetch("API_HOST", "bops.localhost:3000") config.api_protocol = ENV["PROTOCOL"] diff --git a/lib/quiet_logger.rb b/lib/quiet_logger.rb deleted file mode 100644 index abb0277c..00000000 --- a/lib/quiet_logger.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class QuietLogger - PATH_INFO = "PATH_INFO" - - attr_reader :app, :options, :paths - - def initialize(app, options = {}) - @app = app - @options = options - @paths = Array(options[:paths]) - end - - def call(env) - if silence_request?(env) - logger.silence { app.call(env) } - else - app.call(env) - end - end - - private - - def silence_request?(env) - paths.any? { |path| path === env[PATH_INFO] } # rubocop:disable Style/CaseEquality - end - - def logger - Rails.logger - end -end From f9a13eca2609b8d7c3343bb77df0529c2443c1e1 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:47:58 +0000 Subject: [PATCH 04/12] Move application config to a YAML file --- config/application.rb | 8 ++++---- config/application.yml | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 config/application.yml diff --git a/config/application.rb b/config/application.rb index 0a47fd0e..0c9a6708 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,9 +44,9 @@ class Application < Rails::Application config.action_controller.forgery_protection_origin_check = false - config.os_vector_tiles_api_key = ENV["OS_VECTOR_TILES_API_KEY"] - config.api_host = ENV.fetch("API_HOST", "bops.localhost:3000") - config.api_protocol = ENV["PROTOCOL"] - config.api_bearer = ENV["API_BEARER"] + # Load config from application.yml + config_for(:application).each do |key, value| + config.send(:"#{key}=", value) + end end end diff --git a/config/application.yml b/config/application.yml new file mode 100644 index 00000000..a843e319 --- /dev/null +++ b/config/application.yml @@ -0,0 +1,5 @@ +shared: + os_vector_tiles_api_key: <%= ENV["OS_VECTOR_TILES_API_KEY"] %> + api_host: <%= ENV.fetch("API_HOST", "bops.localhost:3000") %> + api_protocol: <%= ENV["PROTOCOL"] %> + api_bearer: <%= ENV["API_BEARER"] %> From 59531eb02f1dffef9bd222bfa548b420ab14a682 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:48:23 +0000 Subject: [PATCH 05/12] Remove unused railtie requires --- config/application.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/application.rb b/config/application.rb index 0c9a6708..9a27c755 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,17 +5,10 @@ require "rails" # Pick the frameworks you want: require "active_model/railtie" -# require "active_job/railtie" require "active_record/railtie" -# require "active_storage/engine" require "action_controller/railtie" -# require "action_mailer/railtie" -# require "action_mailbox/engine" -# require "action_text/engine" require "action_view/railtie" -# require "action_cable/engine" require "sprockets/railtie" -# require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. From 31a87b31914228c59823ec34098dd14933f1258a Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:48:53 +0000 Subject: [PATCH 06/12] Configure application time zone --- config/application.rb | 8 +++----- .../ownership_certificate_validation_request_spec.rb | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config/application.rb b/config/application.rb index 9a27c755..e90a30f8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,13 +28,11 @@ class Application < Rails::Application # # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - # Don't generate system test files. - config.generators.system_tests = nil + # Configure application time zone + config.time_zone = "London" + # Don't check Origin header in CSRF checks config.action_controller.forgery_protection_origin_check = false # Load config from application.yml diff --git a/spec/system/ownership_certificate_validation_request_spec.rb b/spec/system/ownership_certificate_validation_request_spec.rb index 603e1bd9..2b7e35e8 100644 --- a/spec/system/ownership_certificate_validation_request_spec.rb +++ b/spec/system/ownership_certificate_validation_request_spec.rb @@ -174,7 +174,7 @@ town: "London", country: "", postcode: "E16LT", - notice_given_at: "2023-02-01T00:00:00.000Z" + notice_given_at: "2023-02-01T00:00:00.000+00:00" }, { name: "Bob", From f79198c16f6d1a35883b0cc12b6f0da9f158ba18 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:49:13 +0000 Subject: [PATCH 07/12] Ensure migrations are applied before running specs --- spec/rails_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4b6b24e6..790aa55a 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "spec_helper" - ENV["RAILS_ENV"] ||= "test" require File.expand_path("../config/environment", __dir__) @@ -11,6 +10,13 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end + RSpec.configure do |config| config.file_fixture_path = Rails.root.join("spec/fixtures") From 41a75eca5484914472eac68bff92707d35c55512 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:49:47 +0000 Subject: [PATCH 08/12] Update db/schema.rb for Rails 7.2 --- db/schema.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 36e69cf6..30b96df2 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[7.1].define(version: 2024_01_02_155438) do +ActiveRecord::Schema[7.2].define(version: 2024_01_02_155438) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -40,5 +40,4 @@ t.datetime "updated_at", null: false t.string "change_access_id" end - end From 1b7fb2a967185f0c5121dd9ba189a73eba44cb23 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 28 Oct 2024 11:50:30 +0000 Subject: [PATCH 09/12] Configure the form builder globally --- .../edit.html.erb | 3 +-- .../_form.html.erb | 3 +-- app/views/fee_change_validation_requests/_form.html.erb | 3 +-- .../heads_of_term_validation_requests/_form.html.erb | 3 +-- app/views/land_owners/new.html.erb | 5 ++--- app/views/neighbour_responses/new.html.erb | 3 +-- .../other_change_validation_requests/_form.html.erb | 3 +-- .../_form.html.erb | 3 +-- app/views/ownership_certificates/edit.html.erb | 1 - app/views/ownership_certificates/new.html.erb | 3 +-- .../_form.html.erb | 3 +-- .../_form.html.erb | 3 +-- .../_red_line_boundary_map.html.erb | 2 +- .../edit.html.erb | 3 +-- .../time_extension_validation_requests/_form.html.erb | 3 +-- config/initializers/govuk_design_system_formbuilder.rb | 9 +++++++++ 16 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 config/initializers/govuk_design_system_formbuilder.rb diff --git a/app/views/additional_document_validation_requests/edit.html.erb b/app/views/additional_document_validation_requests/edit.html.erb index 8fcbf4ec..af3e19e1 100644 --- a/app/views/additional_document_validation_requests/edit.html.erb +++ b/app/views/additional_document_validation_requests/edit.html.erb @@ -9,8 +9,7 @@ <%= form_with scope: :additional_document_validation_request, url: additional_document_validation_request_path(@validation_request["id"], planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"]), - method: :patch, - builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %> + method: :patch do |form| %> <% if @additional_document_validation_request.errors.any? %>