1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Merge branch 'master' of github.com:mperham/sidekiq

This commit is contained in:
Mike Perham 2012-03-26 19:54:10 -07:00
commit fb0b09d563
3 changed files with 30 additions and 0 deletions

View file

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

View file

@ -1,5 +1,6 @@
module Sidekiq
def self.hook_rails!
return unless Sidekiq.options[:enable_rails_extensions]
if defined?(ActiveRecord)
ActiveRecord::Base.extend(Sidekiq::Extensions::ActiveRecord)
ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)

View file

@ -0,0 +1,28 @@
require 'helper'
require 'sidekiq'
class TestExtensionConfiguration < MiniTest::Unit::TestCase
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_equal true, Sidekiq.options[:enable_rails_extensions]
end
it 'should extend ActiveRecord and ActiveMailer if enable_rails_extensions is true' do
assert_equal ActionMailer::Base, Sidekiq.hook_rails!
end
it 'should not extend ActiveRecord and ActiveMailer if enable_rails_extensions is false' do
Sidekiq.options = { :enable_rails_extensions => false }
assert_equal nil, Sidekiq.hook_rails!
end
end
end