Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix solid queue tests #222

Merged
merged 8 commits into from
Oct 15, 2024
7 changes: 7 additions & 0 deletions .github/workflows/judoscale-rails-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-rails-7-1
adamlogic marked this conversation as resolved.
Show resolved Hide resolved
- Gemfile-rails-7-0
- Gemfile-rails-6-1
ruby:
Expand All @@ -26,8 +27,14 @@ jobs:
exclude:
- gemfile: Gemfile
ruby: "2.6"
- gemfile: Gemfile
ruby: "2.7"
- gemfile: Gemfile
ruby: "3.0"
- gemfile: Gemfile-rails-7-0
ruby: "2.6"
- gemfile: Gemfile-rails-7-1
ruby: "2.6"
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/judoscale-rails/${{ matrix.gemfile }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/judoscale-solid_queue-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-solid_queue-0-3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Gemfile to test against solid_queue v0.3 so we get coverage on minimum version supported

ruby:
- "2.7"
- "3.0"
Expand Down
9 changes: 9 additions & 0 deletions judoscale-rails/Gemfile-rails-7-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source "https://rubygems.org"

gemspec name: "judoscale-rails"

gem "judoscale-ruby", path: "../judoscale-ruby"
gem "railties", "~> 7.1"
gem "minitest"
gem "minitest-stub-const"
gem "rake"
10 changes: 10 additions & 0 deletions judoscale-solid_queue/Gemfile-solid_queue-0-3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source "https://rubygems.org"

gemspec name: "judoscale-solid_queue"

gem "judoscale-ruby", path: "../judoscale-ruby"
gem "solid_queue", "~> 0.3.0"
gem "activerecord"
gem "pg"
gem "minitest"
gem "rake"
10 changes: 9 additions & 1 deletion judoscale-solid_queue/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# https://github.com/rails/solid_queue/commit/5ff6e0178bbe7c0cf93134ea2ef974c1dfc09a09
require "active_support"
require "active_support/core_ext/numeric/time"
# It seems SolidQueue v0.7.1+ blows up without requiring activemodel.
# It should be a dependency for them through activerecord, but they may not be requiring it properly.
require "active_model"
adamlogic marked this conversation as resolved.
Show resolved Hide resolved
require "judoscale-solid_queue"

require "minitest/autorun"
Expand Down Expand Up @@ -41,10 +44,15 @@ class TestRailsApp < Rails::Application
Minitest.after_run {
ActiveRecord::Tasks::DatabaseTasks.drop(DATABASE_URL)
}
ActiveRecord::Base.establish_connection(DATABASE_URL)
ActiveRecord::Base.configurations = {test: {url: DATABASE_URL}}
ActiveRecord::Base.establish_connection(:test)
adamlogic marked this conversation as resolved.
Show resolved Hide resolved

# Suppress migration noise.
ENV["VERBOSE"] ||= "false"
# SolidQueue v0.8+ merged migrations into a single schema file, which we load directly into our test DB.
# Migrations are still executed afterwards, as they may add them in the future if schema changes are needed.
SCHEMA_FILE = SolidQueue::Engine.config.paths["lib"].paths.first.join("generators", "solid_queue", "install", "templates", "db", "queue_schema.rb")
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(ActiveRecord.schema_format, SCHEMA_FILE) if SCHEMA_FILE.exist?
adamlogic marked this conversation as resolved.
Show resolved Hide resolved
# Add SolidQueue migration path to Active Record to migrate to the latest automatically.
# It seems we can't only set it on `DatabaseTasks` as expected, need to set on the `Migrator` directly instead.
ActiveRecord::Migrator.migrations_paths += SolidQueue::Engine.config.paths["db/migrate"].existent
Expand Down