diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd50a94f..5664621e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [Full changelog][unreleased] +## Release 154 - 2024-12-05 + +[Full changelog][154] + +- Remove Spring from development +- Switch to the Zeitwerk autoloader +- Use Rails 6.1 default configuration + ## Release 153 - 2024-12-02 [Full changelog][153] @@ -1719,7 +1727,8 @@ - Planned start and end dates are mandatory - Actual start and end dates must not be in the future -[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-153...HEAD +[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-154...HEAD +[154]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-153...release-154 [153]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-152...release-153 [152]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-151...release-152 [151]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-150...release-151 diff --git a/Gemfile b/Gemfile index bb0e50ffe..602b64616 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ ruby File.read(".ruby-version").strip gem "acts_as_tree" gem "addressable" gem "audited", "~> 5.4" -gem "aws-sdk-s3", "~> 1.174" +gem "aws-sdk-s3", "~> 1.176" gem "bootsnap", ">= 1.1.0", require: false gem "cssbundling-rails", "~> 1.4" gem "csv-safe" @@ -67,9 +67,6 @@ group :development do gem "better_errors" gem "html2haml" gem "listen", ">= 3.0.5", "< 3.10" - gem "spring" - gem "spring-commands-rspec" - gem "spring-watcher-listen", "~> 2.1.0" gem "rails_layout" gem "web-console", ">= 3.3.0" end diff --git a/Gemfile.lock b/Gemfile.lock index 76eef1919..95c14263f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM activerecord (>= 5.0, < 7.2) request_store (~> 1.2) aws-eventstream (1.3.0) - aws-partitions (1.1013.0) + aws-partitions (1.1017.0) aws-sdk-core (3.214.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) @@ -80,7 +80,7 @@ GEM aws-sdk-kms (1.96.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.174.0) + aws-sdk-s3 (1.176.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -285,14 +285,14 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.4) - nokogiri (1.16.7) + nokogiri (1.16.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) + nokogiri (1.16.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) + nokogiri (1.16.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.16.8-x86_64-linux) racc (~> 1.4) notifications-ruby-client (6.2.0) jwt (>= 1.5, < 3) @@ -354,9 +354,9 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.1) loofah (~> 2.21) - nokogiri (~> 1.14) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) @@ -479,12 +479,6 @@ GEM slim (4.1.0) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) - spring (4.2.1) - spring-commands-rspec (1.0.4) - spring (>= 0.9.1) - spring-watcher-listen (2.1.0) - listen (>= 2.7, < 4.0) - spring (>= 4) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -547,7 +541,7 @@ DEPENDENCIES acts_as_tree addressable audited (~> 5.4) - aws-sdk-s3 (~> 1.174) + aws-sdk-s3 (~> 1.176) better_errors binding_of_caller bootsnap (>= 1.1.0) @@ -608,9 +602,6 @@ DEPENDENCIES sidekiq (~> 7) simplecov (~> 0.22.0) simplecov-lcov (~> 0.8.0) - spring - spring-commands-rspec - spring-watcher-listen (~> 2.1.0) standard strip_attributes tzinfo-data diff --git a/bin/rails b/bin/rails index 40b071ea5..073966023 100755 --- a/bin/rails +++ b/bin/rails @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 7327f471e..4fbf10b96 100755 --- a/bin/rake +++ b/bin/rake @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) require_relative "../config/boot" require "rake" Rake.application.run diff --git a/bin/rspec b/bin/rspec index 053bb19a3..caedbbad6 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,10 +1,5 @@ #!/usr/bin/env ruby # frozen_string_literal: true -begin - load File.expand_path('spring', __dir__) -rescue LoadError => e - raise unless e.message.include?('spring') -end require 'bundler/setup' load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/spring b/bin/spring deleted file mode 100755 index b4147e843..000000000 --- a/bin/spring +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby -if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) - gem "bundler" - require "bundler" - - # Load Spring without loading other gems in the Gemfile, for speed. - Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring| - Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem "spring", spring.version - require "spring/binstub" - rescue Gem::LoadError - # Ignore when Spring is not installed. - end -end diff --git a/config/application.rb b/config/application.rb index 8b5b0d8ce..2b1d2f5c9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,7 +37,7 @@ class Application < Rails::Application end # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 6.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/environments/test.rb b/config/environments/test.rb index 7567499e4..389fb74e0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,14 +10,10 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = !(defined?(Spring::Env) && Spring::Env.new.server_running?) + config.cache_classes = false config.action_view.cache_template_loading = true - # Prevent 'reloading is disabled' errors from Spring - # https://github.com/rails/spring/issues/598 - config.autoloader = :classic - # 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. diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835a..000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/config/spring.rb b/config/spring.rb deleted file mode 100644 index 83202c25d..000000000 --- a/config/spring.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -Spring.watch( - ".ruby-version", - ".rbenv-vars", - "tmp/restart.txt", - "tmp/caching-dev.txt" -) - -Spring.after_fork do - if Rails.env.test? - RSpec.configure do |config| - config.seed = srand % 0xFFFF unless ARGV.any? { |arg| arg =~ /seed/ } - end - end -end diff --git a/doc/background-jobs.md b/doc/background-jobs.md index e6aae55f5..04440986d 100644 --- a/doc/background-jobs.md +++ b/doc/background-jobs.md @@ -1,17 +1,20 @@ # Background jobs -We use Sidekiq (backed by Redis) to handle sending emails. See +We use Sidekiq (backed by Redis) to handle sending emails and other asynchronous +jobs. See [ADR9](/doc/architecture/decisions/0009-use-sidekiq-and-redis-to-send-emails.md). -This might be expanded to handle other asynchronous jobs in the future. The container which runs Sidekiq and processes 'jobs' taken from the Redis queue is defined in AWS task definitions as a "sideCar" container. -## Debugging via console +## Sidekiq UI + +The application provides the Sidekiq UI at `/sidekiq` for service owner users. -### Connect to the instance +## Debugging via console -Currently, dxw developers don't have access to the live application console. +You will first need to get a console on the environment, see the +[documentation](/doc/console-access.md) for details. ### See overview of jobs diff --git a/spec/models/guidance_url_spec.rb b/spec/models/guidance_url_spec.rb index cb008cf0c..113acd9e1 100644 --- a/spec/models/guidance_url_spec.rb +++ b/spec/models/guidance_url_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Activity::GuidanceUrl, type: :model do +RSpec.describe GuidanceUrl, type: :model do describe "#to_s" do it "returns a url if one exists" do url = GuidanceUrl.new(:activity, :programme_status)