From 464e4a78b7076fe97baeb1d97892e76b6c256628 Mon Sep 17 00:00:00 2001 From: Kat <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:43:41 +0000 Subject: [PATCH] Update factory bot, fixture_paths, lint and populate LAs for tests --- Gemfile.lock | 6 +++--- config/environments/production.rb | 2 +- ...d_service_name_to_active_storage_blobs.active_storage.rb | 2 +- ..._create_active_storage_variant_records.active_storage.rb | 5 +++-- db/seeds.rb | 2 +- spec/rails_helper.rb | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b4b6b39dd..088d33d8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -192,10 +192,10 @@ GEM tzinfo event_stream_parser (1.0.0) excon (0.111.0) - factory_bot (6.4.6) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) faker (3.2.3) i18n (>= 1.8.11, < 2) diff --git a/config/environments/production.rb b/config/environments/production.rb index f48a625e0..c337be49b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -44,7 +44,7 @@ Rails.application.configure do # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) + config.logger = ActiveSupport::Logger.new($stdout) .tap { |logger| logger.formatter = ::Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) } diff --git a/db/migrate/20241206142942_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20241206142942_add_service_name_to_active_storage_blobs.active_storage.rb index a15c6ce8e..0a13344fc 100644 --- a/db/migrate/20241206142942_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20241206142942_add_service_name_to_active_storage_blobs.active_storage.rb @@ -6,7 +6,7 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] unless column_exists?(:active_storage_blobs, :service_name) add_column :active_storage_blobs, :service_name, :string - if configured_service = ActiveStorage::Blob.service.name + if configured_service = ActiveStorage::Blob.service.name # rubocop:disable Lint/AssignmentInCondition ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) end diff --git a/db/migrate/20241206142943_create_active_storage_variant_records.active_storage.rb b/db/migrate/20241206142943_create_active_storage_variant_records.active_storage.rb index 94ac83af0..2d2c76b31 100644 --- a/db/migrate/20241206142943_create_active_storage_variant_records.active_storage.rb +++ b/db/migrate/20241206142943_create_active_storage_variant_records.active_storage.rb @@ -4,16 +4,17 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] 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| + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| # rubocop:disable Rails/CreateTableWithTimestamps 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.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 diff --git a/db/seeds.rb b/db/seeds.rb index 2f018be91..9577c9105 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -12,13 +12,13 @@ def find_or_create_user(organisation, email, name, role) end end -unless Rails.env.test? if LocalAuthority.count.zero? la_path = "config/local_authorities_data/initial_local_authorities.csv" service = Imports::LocalAuthoritiesService.new(path: la_path) service.call end +unless Rails.env.test? if LaRentRange.count.zero? Dir.glob("config/rent_range_data/*.csv").each do |path| start_year = File.basename(path, ".csv") diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5f7529554..c663087d5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -51,7 +51,7 @@ rescue ActiveRecord::PendingMigrationError => e end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_paths = ["#{::Rails.root}/spec/fixtures"] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false