diff --git a/Changes.md b/Changes.md index 621818bf..2c2dfe8b 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,8 @@ +HEAD +----------- + +- Remove option to disable Rails hooks. [#401] + 2.3.2 ----------- diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 8e99e6c0..4671acf0 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -23,7 +23,6 @@ module Sidekiq :require => '.', :environment => nil, :timeout => 8, - :enable_rails_extensions => true, } def self.options diff --git a/lib/sidekiq/rails.rb b/lib/sidekiq/rails.rb index 8d2563fd..42387d71 100644 --- a/lib/sidekiq/rails.rb +++ b/lib/sidekiq/rails.rb @@ -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 diff --git a/test/test_extensions.rb b/test/test_extensions.rb index ff0206ff..4ce60d10 100644 --- a/test/test_extensions.rb +++ b/test/test_extensions.rb @@ -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