Browse Source

Update factory bot, fixture_paths, lint and populate LAs for tests

pull/2856/head
Kat 6 months ago
parent
commit
464e4a78b7
  1. 6
      Gemfile.lock
  2. 2
      config/environments/production.rb
  3. 2
      db/migrate/20241206142942_add_service_name_to_active_storage_blobs.active_storage.rb
  4. 5
      db/migrate/20241206142943_create_active_storage_variant_records.active_storage.rb
  5. 2
      db/seeds.rb
  6. 2
      spec/rails_helper.rb

6
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)

2
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) }

2
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

5
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

2
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")

2
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

Loading…
Cancel
Save