1
0
Fork 0
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:
Mike Perham 2012-09-20 20:04:25 -07:00
parent 280a3f4f47
commit b0fa69a915
4 changed files with 9 additions and 29 deletions

View file

@ -1,3 +1,8 @@
HEAD
-----------
- Remove option to disable Rails hooks. [#401]
2.3.2
-----------

View file

@ -23,7 +23,6 @@ module Sidekiq
:require => '.',
:environment => nil,
:timeout => 8,
:enable_rails_extensions => true,
}
def self.options

View file

@ -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

View file

@ -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