diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 00000000..e94f8140 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +defaults diff --git a/.circleci/config.yml b/.circleci/config.yml index e470f4d8..3532e1f7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -123,7 +123,7 @@ jobs: ruby-checks: docker: - - image: "cimg/ruby:3.3.4-node" + - image: "cimg/ruby:3.3.6-node" steps: - checkout - run: @@ -145,7 +145,7 @@ jobs: test: docker: - - image: cimg/ruby:3.3.4-node + - image: cimg/ruby:3.3.6-node environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" @@ -176,7 +176,7 @@ jobs: notify-production-deployment: docker: - - image: cimg/ruby:3.3.4 + - image: cimg/ruby:3.3.6 steps: - checkout diff --git a/.env.development b/.env.development index b0d84b2b..bd9bf123 100644 --- a/.env.development +++ b/.env.development @@ -5,3 +5,5 @@ PORT=3003 SERVICE_DEFAULT=uk TARIFF_API_HOST=http://localhost:3000/ WEB_CONCURRENCY=0 +SECRET_TOKEN=8905973fd3036a2266dc0d8b3c910ce2d9e96e4b1f7c0f2bcf6a3036ecf41d37d1505000ada9ed020accc02eef87e552fb9f139340fbb3e5603e392a04f55131 +SECRET_KEY_BASE=ba5dab038058650fefe03a22bbb7af0645987100cfad65da9313d09cb1d332b0086a742effc441573ef0aefa8b09d8311be2b26b96cecb0f329000c4d0884599 diff --git a/.env.test b/.env.test index f55c39ea..0096d18e 100644 --- a/.env.test +++ b/.env.test @@ -3,3 +3,5 @@ API_SERVICE_BACKEND_URL_OPTIONS={"uk":"http://localhost:3018","xi":"http://local BEARER_TOKEN=tariff-api-test-token SERVICE_DEFAULT=uk TARIFF_API_HOST='http://api.example.org' +SECRET_TOKEN=e8ad2c6a26c5595f77e3f294387bd842b52a1540577d75ab2321780f590403bbb41d1acad03ccbc46063e78a207ad79ba9984918c40c3b1fda4f8b7fa88cabc5 +SECRET_KEY_BASE=84801eabac9c9fe3df53fc65512f9c34029064219ae91bc80ce8bc3053bcec56f4357c5615408d96392ef945c5dcfed42cde2531ce021aa610911febf9ff7458 diff --git a/.gitignore b/.gitignore index f6682cba..ee3efc6f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,10 @@ vendor yarn-error.log .byebug_history .direnv + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity diff --git a/.rubocop.yml b/.rubocop.yml index 5a60a1ba..1662c4d7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,15 +6,15 @@ inherit_gem: require: rubocop-rspec AllCops: - TargetRubyVersion: 3.3.4 + TargetRubyVersion: 3.3.6 Exclude: - - 'db/schema.rb' - - 'vendor/**/*' - - 'bin/**' - - 'db/**/*' - - 'tmp/**/*' - - 'config/**/*' - - 'node_modules/**/*' + - "db/schema.rb" + - "vendor/**/*" + - "bin/**" + - "db/**/*" + - "tmp/**/*" + - "config/**/*" + - "node_modules/**/*" Layout/LineLength: Max: 120 Layout/AccessModifierIndentation: diff --git a/.ruby-version b/.ruby-version index a0891f56..9c25013d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.4 +3.3.6 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..5aa8e0c3 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.3.6 diff --git a/Dockerfile b/Dockerfile index e389faf3..50be6ad0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build compilation image -FROM ruby:3.3.4-alpine3.19 as builder +FROM ruby:3.3.6-alpine3.19 as builder # The application runs from /app WORKDIR /app @@ -43,7 +43,7 @@ RUN rm -rf node_modules log tmp && \ find /usr/local/bundle/gems -name "*.html" -delete # Build runtime image -FROM ruby:3.3.4-alpine3.19 as production +FROM ruby:3.3.6-alpine3.19 as production RUN apk add --update --no-cache tzdata postgresql-dev nodejs && \ cp /usr/share/zoneinfo/Europe/London /etc/localtime && \ diff --git a/Gemfile b/Gemfile index 5919583b..cb5056da 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ ruby File.read('.ruby-version').chomp # Server gem 'puma' -gem 'rails', '~> 7.1.2' +gem 'rails', '~> 8.0.0' gem 'routing-filter', github: 'trade-tariff/routing-filter' diff --git a/Gemfile.lock b/Gemfile.lock index d7a9cefe..da26df4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,86 +9,83 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.4) - actionpack (= 7.1.4) - activesupport (= 7.1.4) + actioncable (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.4) - actionpack (= 7.1.4) - activejob (= 7.1.4) - activerecord (= 7.1.4) - activestorage (= 7.1.4) - activesupport (= 7.1.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.4) - actionpack (= 7.1.4) - actionview (= 7.1.4) - activejob (= 7.1.4) - activesupport (= 7.1.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) + mail (>= 2.8.0) + actionmailer (8.0.0) + actionpack (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activesupport (= 8.0.0) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.4) - actionview (= 7.1.4) - activesupport (= 7.1.4) + actionpack (8.0.0) + actionview (= 8.0.0) + activesupport (= 8.0.0) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.4) - actionpack (= 7.1.4) - activerecord (= 7.1.4) - activestorage (= 7.1.4) - activesupport (= 7.1.4) + useragent (~> 0.16) + actiontext (8.0.0) + actionpack (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.4) - activesupport (= 7.1.4) + actionview (8.0.0) + activesupport (= 8.0.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.4) - activesupport (= 7.1.4) + activejob (8.0.0) + activesupport (= 8.0.0) globalid (>= 0.3.6) - activemodel (7.1.4) - activesupport (= 7.1.4) - activerecord (7.1.4) - activemodel (= 7.1.4) - activesupport (= 7.1.4) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) - activestorage (7.1.4) - actionpack (= 7.1.4) - activejob (= 7.1.4) - activerecord (= 7.1.4) - activesupport (= 7.1.4) + activestorage (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activesupport (= 8.0.0) marcel (~> 1.0) - activesupport (7.1.4) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) backport (1.2.0) base64 (0.2.0) - benchmark (0.3.0) + benchmark (0.4.0) bigdecimal (3.1.8) bootsnap (1.18.4) msgpack (~> 1.2) @@ -125,7 +122,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.4) + date (3.4.1) diff-lcs (1.5.1) docile (1.4.1) dotenv (3.1.2) @@ -144,7 +141,7 @@ GEM factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) - faraday (1.10.3) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -197,10 +194,10 @@ GEM nokogiri (~> 1.12) rinku (~> 2.0) sanitize (~> 6) - govuk-components (5.6.1) + govuk-components (5.7.1) html-attributes-utils (~> 1.0.0, >= 1.0.0) pagy (>= 6, < 10) - view_component (>= 3.9, < 3.15) + view_component (>= 3.18, < 3.21) govuk_app_config (9.14.1) logstasher (~> 2.1) opentelemetry-exporter-otlp (>= 0.25, < 0.30) @@ -218,9 +215,9 @@ GEM activemodel (>= 6.1) activesupport (>= 6.1) html-attributes-utils (~> 1) - govuk_personalisation (1.0.0) + govuk_personalisation (1.1.0) plek (>= 1.9.0) - rails (>= 6, < 8) + rails (>= 6, < 9) govuk_publishing_components (43.5.0) govuk_app_config govuk_personalisation (>= 0.7.0) @@ -267,7 +264,7 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.3) - logger (1.6.1) + logger (1.6.2) lograge (0.14.0) actionpack (>= 4) activesupport (>= 4) @@ -290,14 +287,13 @@ GEM method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.7) - minitest (5.25.1) + minitest (5.25.4) msgpack (1.7.2) multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) multipart-post (2.4.1) - mutex_m (0.2.0) - net-imap (0.4.16) + net-imap (0.5.1) date net-protocol net-pop (0.1.2) @@ -567,20 +563,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.4) - actioncable (= 7.1.4) - actionmailbox (= 7.1.4) - actionmailer (= 7.1.4) - actionpack (= 7.1.4) - actiontext (= 7.1.4) - actionview (= 7.1.4) - activejob (= 7.1.4) - activemodel (= 7.1.4) - activerecord (= 7.1.4) - activestorage (= 7.1.4) - activesupport (= 7.1.4) + rails (8.0.0) + actioncable (= 8.0.0) + actionmailbox (= 8.0.0) + actionmailer (= 8.0.0) + actionpack (= 8.0.0) + actiontext (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activemodel (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) bundler (>= 1.15.0) - railties (= 7.1.4) + railties (= 8.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -592,10 +588,10 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.4) - actionpack (= 7.1.4) - activesupport (= 7.1.4) - irb + railties (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -683,6 +679,7 @@ GEM sanitize (6.1.3) crass (~> 1.0.2) nokogiri (>= 1.12.0) + securerandom (0.4.0) semantic_range (3.0.0) sentry-rails (5.19.0) railties (>= 5.0) @@ -748,9 +745,11 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) + uri (1.0.2) + useragent (0.16.11) version_gem (1.1.4) - view_component (3.14.0) - activesupport (>= 5.2.0, < 8.0) + view_component (3.20.0) + activesupport (>= 5.2.0, < 8.1) concurrent-ruby (~> 1.0) method_source (~> 1.0) warden (1.2.9) @@ -807,7 +806,7 @@ DEPENDENCIES pry-rails puma pundit - rails (~> 7.1.2) + rails (~> 8.0.0) rails-controller-testing redis responders @@ -827,7 +826,7 @@ DEPENDENCIES webpacker RUBY VERSION - ruby 3.3.4p94 + ruby 3.3.6p108 BUNDLED WITH 2.5.11 diff --git a/README.md b/README.md index 246d5953..2c3b5213 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ environment files, see the backend's [README](https://github.com/trade-tariff/tr > Make sure you install and enable all pre-commit hooks https://pre-commit.com/ -* Ruby 3.2.2 +* Ruby 3.3.6 * NodeJS * PostgreSQL diff --git a/app/models/import_task.rb b/app/models/import_task.rb index 3827be5e..262919bc 100644 --- a/app/models/import_task.rb +++ b/app/models/import_task.rb @@ -1,4 +1,5 @@ class ImportTask < ApplicationRecord include ImportFileUploader::Attachment(:file) - enum status: { in_queue: 0, in_progress: 1, failed: 2, successful: 3 } + + enum :status, in_queue: 0, in_progress: 1, failed: 2, successful: 3 end diff --git a/bin/webpack b/bin/webpack index 06ee24ed..1031168d 100755 --- a/bin/webpack +++ b/bin/webpack @@ -3,10 +3,6 @@ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" ENV["NODE_ENV"] ||= "development" -unless ENV["RAILS_ENV"] == "production" - ENV["NODE_OPTIONS"] = "--openssl-legacy-provider" -end - require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) diff --git a/config/application.rb b/config/application.rb index 26d70990..09617859 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,11 +1,13 @@ require_relative 'boot' require 'rails/all' +require_relative '../lib/activesupport/basic_object' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) + APP_SLUG = 'trade-tariff-admin'.freeze module TradeTariffAdmin diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index ba6f136c..bd09282d 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,8 +1,9 @@ +require "securerandom" # Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -TradeTariffAdmin::Application.config.secret_token = Rails.application.secrets.secret_token -TradeTariffAdmin::Application.config.secret_key_base = Rails.application.secrets.secret_key_base +TradeTariffAdmin::Application.config.secret_token = ENV["SECRET_TOKEN"] +TradeTariffAdmin::Application.config.secret_key_base = ENV["SECRET_KEY_BASE"] diff --git a/config/secrets.yml b/config/secrets.yml deleted file mode 100644 index 5c1516f4..00000000 --- a/config/secrets.yml +++ /dev/null @@ -1,25 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. - -# Make sure the secrets in this file are kept private -# if you're sharing your code publicly. - -development: - secret_token: 8905973fd3036a2266dc0d8b3c910ce2d9e96e4b1f7c0f2bcf6a3036ecf41d37d1505000ada9ed020accc02eef87e552fb9f139340fbb3e5603e392a04f55131 - secret_key_base: ba5dab038058650fefe03a22bbb7af0645987100cfad65da9313d09cb1d332b0086a742effc441573ef0aefa8b09d8311be2b26b96cecb0f329000c4d0884599 - -test: - secret_token: e8ad2c6a26c5595f77e3f294387bd842b52a1540577d75ab2321780f590403bbb41d1acad03ccbc46063e78a207ad79ba9984918c40c3b1fda4f8b7fa88cabc5 - secret_key_base: 84801eabac9c9fe3df53fc65512f9c34029064219ae91bc80ce8bc3053bcec56f4357c5615408d96392ef945c5dcfed42cde2531ce021aa610911febf9ff7458 - -# Do not keep production secrets in the repository, -# instead read values from the environment. -production: - secret_token: <%= ENV["SECRET_TOKEN"] %> - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/lib/activesupport/basic_object.rb b/lib/activesupport/basic_object.rb new file mode 100644 index 00000000..ea589cf2 --- /dev/null +++ b/lib/activesupport/basic_object.rb @@ -0,0 +1,4 @@ +module ActiveSupport + class BasicObject < BasicObject + end +end diff --git a/package.json b/package.json index ea9e9484..fa71593e 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,19 @@ "name": "trade-tariff-admin", "private": true, "dependencies": { - "@rails/webpacker": "^5.4.4", + "@rails/webpacker": "5.4.4", "autosize": "^6.0.1", "chart.js": "^4.4.4", "govuk-frontend": "5.6.0", - "rails-ujs": "^5.2.8" + "rails-ujs": "^5.2.8", + "webpack": "^4.46.0", + "webpack-cli": "^3.3.12" }, "devDependencies": { "@webpack-cli/serve": "^2.0.5", "eslint": "^9.10.0", "eslint-config-google": "^0.14.0", - "webpack-dev-server": "^5.1.0" + "webpack-dev-server": "^3" }, "license": "MIT" } diff --git a/spec/models/quota_order_numbers/quota_definition_spec.rb b/spec/models/quota_order_numbers/quota_definition_spec.rb index 8a3f6f84..31b9ed3e 100644 --- a/spec/models/quota_order_numbers/quota_definition_spec.rb +++ b/spec/models/quota_order_numbers/quota_definition_spec.rb @@ -96,7 +96,7 @@ context 'when there are no quota order number origins' do subject(:quota_definition) { build(:quota_definition, :without_quota_order_number_origins) } - it { expect(quota_definition.quota_order_number_origins).to eq([]) } + it { expect(quota_definition.quota_order_number_origins.count).to eq(0) } end end @@ -112,7 +112,7 @@ context 'when there are no quota unsuspension events' do subject(:quota_definition) { build(:quota_definition, :without_quota_unsuspension_events) } - it { expect(quota_definition.quota_unsuspension_events).to eq([]) } + it { expect(quota_definition.quota_unsuspension_events.count).to eq(0) } end end @@ -128,7 +128,7 @@ context 'when there are no quota exhaustion events' do subject(:quota_definition) { build(:quota_definition, :without_quota_exhaustion_events) } - it { expect(quota_definition.quota_exhaustion_events).to eq([]) } + it { expect(quota_definition.quota_exhaustion_events.count).to eq(0) } end end @@ -144,7 +144,7 @@ context 'when there are no quota reopening events' do subject(:quota_definition) { build(:quota_definition, :without_quota_reopening_events) } - it { expect(quota_definition.quota_reopening_events).to eq([]) } + it { expect(quota_definition.quota_reopening_events.count).to eq(0) } end end @@ -160,7 +160,7 @@ context 'when there are no quota unblocking events' do subject(:quota_definition) { build(:quota_definition, :without_quota_unblocking_events) } - it { expect(quota_definition.quota_unblocking_events).to eq([]) } + it { expect(quota_definition.quota_unblocking_events.count).to eq(0) } end end @@ -176,7 +176,7 @@ context 'when there are no quota unblocking events' do subject(:quota_definition) { build(:quota_definition, :without_quota_critical_events) } - it { expect(quota_definition.quota_critical_events).to eq([]) } + it { expect(quota_definition.quota_critical_events.count).to eq(0) } end end