Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
module Flaredown
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.1
config.load_defaults 7.2
config.add_autoload_paths_to_load_path = false
config.active_support.cache_format_version = 7.1

Expand Down
5 changes: 5 additions & 0 deletions backend/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Only use :id for inspections in production. `inspect` on an Active Record
# object otherwise renders every column, which is how attribute values reach
# logs and exception reports -- and on this app those values are health data.
config.active_record.attributes_for_inspect = [:id]

# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
Expand Down
70 changes: 0 additions & 70 deletions backend/config/initializers/new_framework_defaults_7_2.rb

This file was deleted.

43 changes: 43 additions & 0 deletions backend/spec/jobs/enqueue_after_transaction_commit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require "rails_helper"

# `load_defaults 7.2` sets active_job.enqueue_after_transaction_commit to :default,
# which hands the decision to the queue adapter. Sidekiq keeps its queue in Redis
# rather than the Active Record database, so it takes the abstract adapter's `true`:
# a job enqueued inside a transaction waits for the commit, and a rollback drops it
# instead of leaving Sidekiq holding a job whose rows were never written.
#
# HelloWorldJob is used because it is inert -- nothing else references it, and
# performing it only writes a log line.
describe "enqueuing an Active Job inside an Active Record transaction" do
include ActiveJob::TestHelper

it "waits for the transaction to commit" do
ActiveRecord::Base.transaction do
HelloWorldJob.perform_later

expect(enqueued_jobs).to be_empty
end

expect(enqueued_jobs.size).to eq(1)
end

it "drops the job when the transaction rolls back" do
ActiveRecord::Base.transaction do
HelloWorldJob.perform_later

raise ActiveRecord::Rollback
end

expect(enqueued_jobs).to be_empty
end

# DatabaseCleaner's :transaction strategy wraps every example in a transaction
# opened with `joinable: false`, and ActiveRecord.after_all_transactions_commit
# skips non-joinable transactions. So an enqueue outside an explicit transaction
# still happens immediately, which is what the rest of the suite assumes.
it "enqueues immediately outside a transaction" do
HelloWorldJob.perform_later

expect(enqueued_jobs.size).to eq(1)
end
end
Loading