mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Remove optionality of Rails hooks, #401
This commit is contained in:
parent
280a3f4f47
commit
b0fa69a915
4 changed files with 9 additions and 29 deletions
|
@ -1,3 +1,8 @@
|
|||
HEAD
|
||||
-----------
|
||||
|
||||
- Remove option to disable Rails hooks. [#401]
|
||||
|
||||
2.3.2
|
||||
-----------
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ module Sidekiq
|
|||
:require => '.',
|
||||
:environment => nil,
|
||||
:timeout => 8,
|
||||
:enable_rails_extensions => true,
|
||||
}
|
||||
|
||||
def self.options
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
module Sidekiq
|
||||
def self.hook_rails!
|
||||
return unless Sidekiq.options[:enable_rails_extensions]
|
||||
if defined?(ActiveRecord)
|
||||
ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
|
||||
if defined?(::ActiveRecord)
|
||||
::ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
|
||||
end
|
||||
|
||||
if defined?(ActionMailer)
|
||||
ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
||||
if defined?(::ActionMailer)
|
||||
::ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -64,27 +64,4 @@ class TestExtensions < MiniTest::Unit::TestCase
|
|||
SomeClass.delay.doit(Date.today)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sidekiq rails extensions configuration' do
|
||||
before do
|
||||
@options = Sidekiq.options
|
||||
end
|
||||
|
||||
after do
|
||||
Sidekiq.options = @options
|
||||
end
|
||||
|
||||
it 'should set enable_rails_extensions option to true by default' do
|
||||
assert Sidekiq.options[:enable_rails_extensions]
|
||||
end
|
||||
|
||||
it 'should extend ActiveRecord and ActiveMailer if enable_rails_extensions is true' do
|
||||
assert Sidekiq.hook_rails!
|
||||
end
|
||||
|
||||
it 'should not extend ActiveRecord and ActiveMailer if enable_rails_extensions is false' do
|
||||
Sidekiq.options = { :enable_rails_extensions => false }
|
||||
refute Sidekiq.hook_rails!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue