mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Do not allow Sidekiq::Worker in AJ::Base classes, #2424
It will not work as intended and lead to much sorrow and misery.
This commit is contained in:
parent
c96cc21855
commit
c685d6928c
2 changed files with 25 additions and 0 deletions
|
@ -24,6 +24,8 @@ module Sidekiq
|
|||
attr_accessor :jid
|
||||
|
||||
def self.included(base)
|
||||
raise ArgumentError, "You cannot include Sidekiq::Worker in an ActiveJob: #{base.name}" if base.ancestors.any? {|c| c.name == 'ActiveJob::Base' }
|
||||
|
||||
base.extend(ClassMethods)
|
||||
base.class_attribute :sidekiq_options_hash
|
||||
base.class_attribute :sidekiq_retry_in_block
|
||||
|
|
23
test/test_rails.rb
Normal file
23
test/test_rails.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require_relative 'helper'
|
||||
require 'sidekiq'
|
||||
require 'sidekiq/web_helpers'
|
||||
|
||||
$HAS_AJ = true
|
||||
begin
|
||||
require 'active_job'
|
||||
rescue
|
||||
$NO_AJ = false
|
||||
end
|
||||
|
||||
class TestRails < Sidekiq::Test
|
||||
|
||||
describe 'ActiveJob' do
|
||||
it 'does not allow Sidekiq::Worker in AJ::Base classes' do
|
||||
ex = assert_raises ArgumentError do
|
||||
c = Class.new(ActiveJob::Base)
|
||||
c.include Sidekiq::Worker
|
||||
end
|
||||
assert_includes ex.message, "cannot include"
|
||||
end if $HAS_AJ
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue