Skip to content

Commit

Permalink
Merge pull request #32 from basecamp/solid-queue-record-load-hooks
Browse files Browse the repository at this point in the history
Add load hooks for SolidQueue::Record
  • Loading branch information
djmb authored Nov 1, 2023
2 parents 290b360 + 45af661 commit b9e8228
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/solid_queue/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ class Record < ActiveRecord::Base
self.abstract_class = true
end
end

ActiveSupport.run_load_hooks :solid_queue_record, SolidQueue::Record
6 changes: 6 additions & 0 deletions test/dummy/config/initializers/solid_queue_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rails.application.config.x.solid_queue_record_hook_ran = false

ActiveSupport.on_load(:solid_queue_record) do
raise "Expected to run on SolidQueue::Record, got #{self.inspect}" unless self == SolidQueue::Record
Rails.application.config.x.solid_queue_record_hook_ran = true
end
7 changes: 7 additions & 0 deletions test/unit/hooks_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class HooksTest < ActiveSupport::TestCase
test "solid_queue_record hook ran" do
assert Rails.application.config.x.solid_queue_record_hook_ran
end
end

0 comments on commit b9e8228

Please sign in to comment.