diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index adb6b9c8..eef17fa5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,5 +53,3 @@ jobs: bin/rails db:setup - name: Run tests run: bin/rails test - - name: Run tests with separate connection - run: SEPARATE_CONNECTION=1 bin/rails test diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 502f70cb..8fa76e8c 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -28,9 +28,5 @@ class Application < Rails::Application # config.eager_load_paths << Rails.root.join("extras") config.active_job.queue_adapter = :solid_queue - - if ENV["SEPARATE_CONNECTION"] && ENV["TARGET_DB"] != "sqlite" - config.solid_queue.connects_to = { database: { writing: :primary, reading: :replica } } - end end end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index df832026..a5a99232 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -47,6 +47,10 @@ # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true + # Replace the default in-process and non-durable queuing backend for Active Job. + config.active_job.queue_adapter = :solid_queue + config.solid_queue.connects_to = { database: { writing: :queue } } + # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true diff --git a/test/models/solid_queue/job_test.rb b/test/models/solid_queue/job_test.rb index a9b3cc59..ed8ba090 100644 --- a/test/models/solid_queue/job_test.rb +++ b/test/models/solid_queue/job_test.rb @@ -249,21 +249,19 @@ class NonOverlappingGroupedJob2 < NonOverlappingJob end end - if ENV["SEPARATE_CONNECTION"] && ENV["TARGET_DB"] != "sqlite" - test "uses a different connection and transaction than the one in use when connects_to is specified" do - assert_difference -> { SolidQueue::Job.count } do - assert_no_difference -> { JobResult.count } do - JobResult.transaction do - JobResult.create!(queue_name: "default", value: "this will be rolled back") - StoreResultJob.perform_later("enqueued inside a rolled back transaction") - raise ActiveRecord::Rollback - end + test "enqueue successfully inside a rolled-back transaction in the app DB" do + assert_difference -> { SolidQueue::Job.count } do + assert_no_difference -> { JobResult.count } do + JobResult.transaction do + JobResult.create!(queue_name: "default", value: "this will be rolled back") + StoreResultJob.perform_later("enqueued inside a rolled back transaction") + raise ActiveRecord::Rollback end end - - job = SolidQueue::Job.last - assert_equal "enqueued inside a rolled back transaction", job.arguments.dig("arguments", 0) end + + job = SolidQueue::Job.last + assert_equal "enqueued inside a rolled back transaction", job.arguments.dig("arguments", 0) end private