From dded348492a1ec559293831c62be46a3c8bea4f5 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 12:45:05 +0000 Subject: [PATCH] Remove activerecord dependency --- features/fixtures/que/app/Gemfile | 1 - features/fixtures/que/app/setup-que.rb | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/features/fixtures/que/app/Gemfile b/features/fixtures/que/app/Gemfile index 9257d550..930f3958 100644 --- a/features/fixtures/que/app/Gemfile +++ b/features/fixtures/que/app/Gemfile @@ -6,7 +6,6 @@ que_version = ENV.fetch("QUE_VERSION") gem "que", "~> #{que_version}" gem "pg", RUBY_VERSION < "2.2.0" ? "0.21.0" : "> 0.21.0" -gem "activerecord", RUBY_VERSION < "2.2.0" ? "4.2.11" : "> 4.2.11" # Install a compatible Minitest version on Ruby <2.3 gem 'minitest', '5.11.3' if RUBY_VERSION < '2.3.0' diff --git a/features/fixtures/que/app/setup-que.rb b/features/fixtures/que/app/setup-que.rb index d96f53f7..1fc5724b 100644 --- a/features/fixtures/que/app/setup-que.rb +++ b/features/fixtures/que/app/setup-que.rb @@ -2,7 +2,6 @@ require 'que' require 'socket' require 'bugsnag' -require 'active_record' QUE_VERSION = ENV.fetch("QUE_VERSION") @@ -30,19 +29,18 @@ raise 'postgres was not ready in time!' unless postgres_ready -ActiveRecord::Base.establish_connection( - adapter: 'postgresql', - database: 'postgres', - username: 'postgres', +$connection = PG::Connection.open( + host: 'postgres', + user: 'postgres', password: 'test_password', - host: 'postgres' + dbname: 'postgres' ) -Que.connection = ActiveRecord - -# Workaround a bug in que/pg -# see https://github.com/que-rb/que/issues/247 if QUE_VERSION == '0.14' + Que.connection = $connection + + # Workaround a bug in que/pg + # see https://github.com/que-rb/que/issues/247 Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| case value when Time then value @@ -50,6 +48,8 @@ else raise "Unexpected time class: #{value.class} (#{value.inspect})" end end +else + Que.connection_proc = ->(&block) { block.call($connection) } end class UnhandledJob < Que::Job