diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f3a12a..218a381 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: lint: runs-on: ubuntu-latest env: - RUBY_VERSION: 4.0.4 + RUBY_VERSION: "4.0" RUBOCOP_CACHE_ROOT: tmp/rubocop steps: - name: Checkout code @@ -34,3 +34,23 @@ jobs: - name: Lint code for consistent style run: bin/rubocop -f github + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: [ "3.3", "3.4", "4.0" ] + env: + RAILS_ENV: test + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests + run: bundle exec rspec diff --git a/.gitignore b/.gitignore index 4d5b25d..8f2097f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ /log/*.log /pkg/ /tmp/ +/spec/dummy/db/*.sqlite3 +/spec/dummy/log/ +/spec/dummy/tmp/ +/coverage/ diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..f6f85f5 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--require spec_helper +--color +--format documentation \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..01e481b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- RSpec test environment with dummy Rails app for request specs +- SimpleCov code coverage reporting with Rails profile and grouped output +- RuboCop and RSpec rake tasks; `bundle exec rake` runs the full suite +- CI test job running `bundle exec rspec` + +## [0.1.0] - 2026-05-18 + +### Added + +- Rails engine scaffold with isolated namespace `SolidQueueDashboard` +- Configurable authentication hook (`SolidQueueDashboard.authenticate`) +- Dashboard page with stat cards for ready, scheduled, running, blocked, failed jobs, queues, and processes +- Queues page with pause/resume actions and latency display +- Jobs page with status filter tabs (ready, scheduled, running, blocked, failed) and per-queue filtering +- Failed jobs page with per-job retry and discard, and bulk discard-all +- Pagination via pagy (v43+) +- Minimal CSS with stat cards, tables, badges, and buttons — no external CSS framework required +- Runtime dependencies: `rails >= 8.1.3`, `solid_queue >= 1.0`, `pagy >= 9.0` +- CI workflow with lint (RuboCop) and test (RSpec) jobs + +[Unreleased]: https://github.com/eclectic-coding/solid_queue_dashboard/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/eclectic-coding/solid_queue_dashboard/releases/tag/v0.1.0 \ No newline at end of file diff --git a/Gemfile b/Gemfile index bbdab32..a154e38 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ gem "sqlite3" # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] gem "rubocop-rails-omakase", require: false -# Start debugger with binding.b [https://github.com/ruby/debug] -# gem "debug", ">= 1.0.0" +gem "rspec-rails" +gem "simplecov", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 9649dfe..5dc6d79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,6 +91,8 @@ GEM connection_pool (3.0.2) crass (1.0.6) date (3.5.1) + diff-lcs (1.6.2) + docile (1.4.1) drb (2.2.3) erb (6.0.4) erubi (1.13.1) @@ -137,6 +139,8 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.5) + nokogiri (1.19.3-aarch64-linux-gnu) + racc (~> 1.4) nokogiri (1.19.3-arm64-darwin) racc (~> 1.4) nokogiri (1.19.3-x86_64-linux-gnu) @@ -207,6 +211,23 @@ GEM regexp_parser (2.12.0) reline (0.6.3) io-console (~> 0.5) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.8) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (8.0.4) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) + rspec-support (3.13.7) rubocop (1.86.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) @@ -237,6 +258,12 @@ GEM rubocop-rails (>= 2.30) ruby-progressbar (1.13.0) securerandom (0.4.1) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) solid_queue (1.4.0) activejob (>= 7.1) activerecord (>= 7.1) @@ -244,6 +271,7 @@ GEM fugit (~> 1.11) railties (>= 7.1) thor (>= 1.3.1) + sqlite3 (2.9.4-aarch64-linux-gnu) sqlite3 (2.9.4-arm64-darwin) sqlite3 (2.9.4-x86_64-linux-gnu) stringio (3.2.0) @@ -265,12 +293,15 @@ GEM zeitwerk (2.7.5) PLATFORMS + aarch64-linux arm64-darwin x86_64-linux DEPENDENCIES puma + rspec-rails rubocop-rails-omakase + simplecov solid_queue_dashboard! sqlite3 @@ -295,6 +326,8 @@ CHECKSUMS connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0 + diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9 erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 @@ -318,6 +351,7 @@ CHECKSUMS net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 + nokogiri (1.19.3-aarch64-linux-gnu) sha256=46b89e5d7b9e844c2ee360794240c6ea2a4e6fa0c5892a4ed487db621224b639 nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 pagy (43.5.4) sha256=2bdf3fa6b1e0cac5bbafe5d077fb24eb971f72f3194f8c6863a0f3867261ce59 @@ -343,6 +377,11 @@ CHECKSUMS rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835 + rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d + rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 + rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df + rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c rubocop (1.86.1) sha256=44415f3f01d01a21e01132248d2fd0867572475b566ca188a0a42133a08d4531 rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 @@ -350,8 +389,12 @@ CHECKSUMS rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 + simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5 + simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246 + simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a solid_queue_dashboard (0.1.0) + sqlite3 (2.9.4-aarch64-linux-gnu) sha256=ecabed721e6eaad54601d2685f09029d90025efc8d931040dc89cb3f8a2080ec sqlite3 (2.9.4-arm64-darwin) sha256=1d5aad413a815d236e96d43f05a1acc600b6cd086800770342a3f9c2877499ff sqlite3 (2.9.4-x86_64-linux-gnu) sha256=537a3eda71b1df1336d0055cbebe55a7317c34870c192c7b6b9d8d0be6871847 stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 diff --git a/Rakefile b/Rakefile index 7ca8948..4ff2b5c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,10 @@ require "bundler/setup" require "bundler/gem_tasks" +require "rubocop/rake_task" +require "rspec/core/rake_task" + +RuboCop::RakeTask.new +RSpec::Core::RakeTask.new(:spec) + +task default: [ :rubocop, :spec ] diff --git a/app/assets/stylesheets/solid_queue_dashboard/application.css b/app/assets/stylesheets/solid_queue_dashboard/application.css index 1975f05..6dae9ab 100644 --- a/app/assets/stylesheets/solid_queue_dashboard/application.css +++ b/app/assets/stylesheets/solid_queue_dashboard/application.css @@ -264,16 +264,16 @@ tbody tr:hover { background: var(--bg); } white-space: nowrap; } -/* Pagination (pagy) */ -.pagy-nav { +/* Pagination (pagy v43 series-nav) */ +nav.pagy { display: flex; justify-content: center; gap: 0.25rem; padding: 1rem; + list-style: none; } -.pagy-nav a, -.pagy-nav span { +nav.pagy a { display: inline-flex; align-items: center; justify-content: center; @@ -288,6 +288,7 @@ tbody tr:hover { background: var(--bg); } background: var(--surface); } -.pagy-nav a:hover { background: var(--bg); } -.pagy-nav span.current { background: var(--primary); color: #fff; border-color: var(--primary); } -.pagy-nav span.gap, .pagy-nav span.disabled { color: var(--muted); } \ No newline at end of file +nav.pagy a:hover:not([aria-disabled="true"]) { background: var(--bg); } +nav.pagy a[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); } +nav.pagy a[role="separator"], +nav.pagy a[aria-disabled="true"] { color: var(--muted); cursor: default; } \ No newline at end of file diff --git a/app/controllers/solid_queue_dashboard/application_controller.rb b/app/controllers/solid_queue_dashboard/application_controller.rb index cecf97d..85c6a91 100644 --- a/app/controllers/solid_queue_dashboard/application_controller.rb +++ b/app/controllers/solid_queue_dashboard/application_controller.rb @@ -1,6 +1,6 @@ module SolidQueueDashboard class ApplicationController < ActionController::Base - include Pagy::Backend + include Pagy::Method before_action :authenticate! diff --git a/app/controllers/solid_queue_dashboard/failed_jobs_controller.rb b/app/controllers/solid_queue_dashboard/failed_jobs_controller.rb index 5f0fdf8..49290f3 100644 --- a/app/controllers/solid_queue_dashboard/failed_jobs_controller.rb +++ b/app/controllers/solid_queue_dashboard/failed_jobs_controller.rb @@ -2,7 +2,7 @@ module SolidQueueDashboard class FailedJobsController < ApplicationController def index scope = SolidQueue::FailedExecution.includes(:job).order(created_at: :desc) - @pagy, @failed_jobs = pagy(scope, limit: 50) + @pagy, @failed_jobs = pagy(:offset, scope, limit: 50) end def retry diff --git a/app/controllers/solid_queue_dashboard/jobs_controller.rb b/app/controllers/solid_queue_dashboard/jobs_controller.rb index 6cf2240..2fef1dc 100644 --- a/app/controllers/solid_queue_dashboard/jobs_controller.rb +++ b/app/controllers/solid_queue_dashboard/jobs_controller.rb @@ -17,7 +17,7 @@ def index scope = scope.where(jobs: { queue_name: @queue }) if @queue.present? scope = scope.order(created_at: :desc) - @pagy, @jobs = pagy(scope, limit: 50) + @pagy, @jobs = pagy(:offset, scope, limit: 50) end end end diff --git a/app/controllers/solid_queue_dashboard/queues_controller.rb b/app/controllers/solid_queue_dashboard/queues_controller.rb index 8165a66..3c46204 100644 --- a/app/controllers/solid_queue_dashboard/queues_controller.rb +++ b/app/controllers/solid_queue_dashboard/queues_controller.rb @@ -2,7 +2,7 @@ module SolidQueueDashboard class QueuesController < ApplicationController def index all_queues = SolidQueue::Queue.all.sort_by(&:name) - @pagy, @queues = pagy_array(all_queues, limit: 50) + @pagy, @queues = pagy(:offset, all_queues, limit: 50) end def pause diff --git a/app/helpers/solid_queue_dashboard/application_helper.rb b/app/helpers/solid_queue_dashboard/application_helper.rb index 269bfb8..d522058 100644 --- a/app/helpers/solid_queue_dashboard/application_helper.rb +++ b/app/helpers/solid_queue_dashboard/application_helper.rb @@ -1,5 +1,4 @@ module SolidQueueDashboard module ApplicationHelper - include Pagy::Frontend end end diff --git a/app/views/solid_queue_dashboard/failed_jobs/index.html.erb b/app/views/solid_queue_dashboard/failed_jobs/index.html.erb index 707cf1c..aef2ee3 100644 --- a/app/views/solid_queue_dashboard/failed_jobs/index.html.erb +++ b/app/views/solid_queue_dashboard/failed_jobs/index.html.erb @@ -51,6 +51,6 @@ <% end %> - <%= pagy_nav(@pagy) if @pagy.pages > 1 %> + <%= raw @pagy.series_nav if @pagy.pages > 1 %> <% end %> diff --git a/app/views/solid_queue_dashboard/jobs/index.html.erb b/app/views/solid_queue_dashboard/jobs/index.html.erb index ad4a4cb..88d2b79 100644 --- a/app/views/solid_queue_dashboard/jobs/index.html.erb +++ b/app/views/solid_queue_dashboard/jobs/index.html.erb @@ -43,7 +43,7 @@ <% end %> - <%= pagy_nav(@pagy) if @pagy.pages > 1 %> + <%= raw @pagy.series_nav if @pagy.pages > 1 %> <% end %> diff --git a/app/views/solid_queue_dashboard/queues/index.html.erb b/app/views/solid_queue_dashboard/queues/index.html.erb index 26ee672..6e6a2a2 100644 --- a/app/views/solid_queue_dashboard/queues/index.html.erb +++ b/app/views/solid_queue_dashboard/queues/index.html.erb @@ -40,6 +40,6 @@ <% end %> - <%= pagy_nav(@pagy) if @pagy.pages > 1 %> + <%= raw @pagy.series_nav if @pagy.pages > 1 %> <% end %> \ No newline at end of file diff --git a/lib/solid_queue_dashboard/engine.rb b/lib/solid_queue_dashboard/engine.rb index 21cdcf5..9f1c6f6 100644 --- a/lib/solid_queue_dashboard/engine.rb +++ b/lib/solid_queue_dashboard/engine.rb @@ -1,3 +1,7 @@ +require "pagy" +require "pagy/toolbox/paginators/method" +require "solid_queue" + module SolidQueueDashboard class Engine < ::Rails::Engine isolate_namespace SolidQueueDashboard diff --git a/solid_queue_dashboard.gemspec b/solid_queue_dashboard.gemspec index d2207d9..356db80 100644 --- a/solid_queue_dashboard.gemspec +++ b/solid_queue_dashboard.gemspec @@ -17,12 +17,14 @@ Gem::Specification.new do |spec| spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." - spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." + spec.metadata["changelog_uri"] = "https://github.com/eclectic-coding/solid_queue_dashboard/blob/main/CHANGELOG.md" spec.files = Dir.chdir(File.expand_path(__dir__)) do Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] end + spec.required_ruby_version = ">= 3.3" + spec.add_dependency "rails", ">= 8.1.3" spec.add_dependency "solid_queue", ">= 1.0" spec.add_dependency "pagy", ">= 9.0" diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb new file mode 100644 index 0000000..8316125 --- /dev/null +++ b/spec/dummy/config/application.rb @@ -0,0 +1,14 @@ +require_relative "boot" + +require "rails/all" + +Bundler.require(*Rails.groups) + +module Dummy + class Application < Rails::Application + config.root = File.expand_path("..", __dir__) + config.load_defaults 8.1 + config.eager_load = false + config.active_support.deprecation = :stderr + end +end diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb new file mode 100644 index 0000000..5624a9d --- /dev/null +++ b/spec/dummy/config/boot.rb @@ -0,0 +1,3 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) + +require "bundler/setup" diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml new file mode 100644 index 0000000..864e54a --- /dev/null +++ b/spec/dummy/config/database.yml @@ -0,0 +1,8 @@ +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +test: + <<: *default + database: <%= File.expand_path("../db/test.sqlite3", __dir__) %> \ No newline at end of file diff --git a/spec/dummy/config/environment.rb b/spec/dummy/config/environment.rb new file mode 100644 index 0000000..80d89bc --- /dev/null +++ b/spec/dummy/config/environment.rb @@ -0,0 +1,5 @@ +ENV["RAILS_ENV"] ||= "test" + +require_relative "application" + +Rails.application.initialize! diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb new file mode 100644 index 0000000..7bc237b --- /dev/null +++ b/spec/dummy/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + mount SolidQueueDashboard::Engine, at: "/jobs" +end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb new file mode 100644 index 0000000..c9ef1cd --- /dev/null +++ b/spec/dummy/db/schema.rb @@ -0,0 +1,129 @@ +ActiveRecord::Schema[8.0].define(version: 1) do + create_table "solid_queue_blocked_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.string "concurrency_key", null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.index [ "concurrency_key", "priority", "job_id" ], name: "index_solid_queue_blocked_executions_for_release" + t.index [ "expires_at", "concurrency_key" ], name: "index_solid_queue_blocked_executions_for_maintenance" + t.index [ "job_id" ], name: "index_solid_queue_blocked_executions_on_job_id", unique: true + end + + create_table "solid_queue_claimed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.bigint "process_id" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_claimed_executions_on_job_id", unique: true + t.index [ "process_id", "job_id" ], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id" + end + + create_table "solid_queue_failed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.text "error" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_failed_executions_on_job_id", unique: true + end + + create_table "solid_queue_jobs", force: :cascade do |t| + t.string "queue_name", null: false + t.string "class_name", null: false + t.text "arguments" + t.integer "priority", default: 0, null: false + t.string "active_job_id" + t.datetime "scheduled_at" + t.datetime "finished_at" + t.string "concurrency_key" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "active_job_id" ], name: "index_solid_queue_jobs_on_active_job_id" + t.index [ "class_name" ], name: "index_solid_queue_jobs_on_class_name" + t.index [ "finished_at" ], name: "index_solid_queue_jobs_on_finished_at" + t.index [ "queue_name", "finished_at" ], name: "index_solid_queue_jobs_for_filtering" + t.index [ "scheduled_at", "finished_at" ], name: "index_solid_queue_jobs_for_alerting" + end + + create_table "solid_queue_pauses", force: :cascade do |t| + t.string "queue_name", null: false + t.datetime "created_at", null: false + t.index [ "queue_name" ], name: "index_solid_queue_pauses_on_queue_name", unique: true + end + + create_table "solid_queue_processes", force: :cascade do |t| + t.string "kind", null: false + t.datetime "last_heartbeat_at", null: false + t.bigint "supervisor_id" + t.integer "pid", null: false + t.string "hostname" + t.text "metadata" + t.datetime "created_at", null: false + t.string "name", null: false + t.index [ "last_heartbeat_at" ], name: "index_solid_queue_processes_on_last_heartbeat_at" + t.index [ "name", "supervisor_id" ], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true + t.index [ "supervisor_id" ], name: "index_solid_queue_processes_on_supervisor_id" + end + + create_table "solid_queue_ready_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_ready_executions_on_job_id", unique: true + t.index [ "priority", "job_id" ], name: "index_solid_queue_poll_all" + t.index [ "queue_name", "priority", "job_id" ], name: "index_solid_queue_poll_by_queue" + end + + create_table "solid_queue_recurring_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "task_key", null: false + t.datetime "run_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_recurring_executions_on_job_id", unique: true + t.index [ "task_key", "run_at" ], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true + end + + create_table "solid_queue_recurring_tasks", force: :cascade do |t| + t.string "key", null: false + t.string "schedule", null: false + t.string "command", limit: 2048 + t.string "class_name" + t.text "arguments" + t.string "queue_name" + t.integer "priority", default: 0 + t.boolean "static", default: true, null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "key" ], name: "index_solid_queue_recurring_tasks_on_key", unique: true + t.index [ "static" ], name: "index_solid_queue_recurring_tasks_on_static" + end + + create_table "solid_queue_scheduled_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "scheduled_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true + t.index [ "scheduled_at", "priority", "job_id" ], name: "index_solid_queue_dispatch_all" + end + + create_table "solid_queue_semaphores", force: :cascade do |t| + t.string "key", null: false + t.integer "value", default: 1, null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "expires_at" ], name: "index_solid_queue_semaphores_on_expires_at" + t.index [ "key", "value" ], name: "index_solid_queue_semaphores_on_key_and_value" + t.index [ "key" ], name: "index_solid_queue_semaphores_on_key", unique: true + end + + add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..6c850b9 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,17 @@ +require "spec_helper" + +ENV["RAILS_ENV"] ||= "test" + +require File.expand_path("dummy/config/environment", __dir__) + +require "rspec/rails" + +# Load solid_queue schema into the test database +ActiveRecord::Schema.verbose = false +load File.expand_path("dummy/db/schema.rb", __dir__) + +RSpec.configure do |config| + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.filter_rails_from_backtrace! +end diff --git a/spec/requests/solid_queue_dashboard/dashboard_spec.rb b/spec/requests/solid_queue_dashboard/dashboard_spec.rb new file mode 100644 index 0000000..135b3da --- /dev/null +++ b/spec/requests/solid_queue_dashboard/dashboard_spec.rb @@ -0,0 +1,15 @@ +require "rails_helper" + +RSpec.describe "Dashboard", type: :request do + describe "GET /jobs" do + it "returns HTTP success" do + get "/jobs" + expect(response).to have_http_status(:ok), -> { response.body } + end + + it "displays the dashboard heading" do + get "/jobs" + expect(response.body).to include("Dashboard") + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..603de47 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,28 @@ +require "simplecov" + +SimpleCov.start "rails" do + add_filter "/spec/" + add_filter "/lib/solid_queue_dashboard/version.rb" + + add_group "Controllers", "app/controllers" + add_group "Helpers", "app/helpers" + add_group "Views", "app/views" + add_group "Library", "lib" +end + +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.shared_context_metadata_behavior = :apply_to_host_groups + config.filter_run_when_matching :focus + config.disable_monkey_patching! + config.warnings = true + config.order = :random + Kernel.srand config.seed +end