mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
replaced order of redis connection creation
This commit is contained in:
parent
89f76e076d
commit
da61fd9fb4
2 changed files with 14 additions and 1 deletions
|
@ -62,8 +62,8 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.redis(&block)
|
def self.redis(&block)
|
||||||
@redis ||= Sidekiq::RedisConnection.create
|
|
||||||
raise ArgumentError, "requires a block" if !block
|
raise ArgumentError, "requires a block" if !block
|
||||||
|
@redis ||= Sidekiq::RedisConnection.create
|
||||||
@redis.with(&block)
|
@redis.with(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,17 @@ class TestSidekiq < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "redis connection" do
|
||||||
|
it "returns error without creating a connection if block is not given" do
|
||||||
|
mock = MiniTest::Mock.new
|
||||||
|
mock.expect :create, nil #Sidekiq::RedisConnection, create
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
|
Sidekiq.redis
|
||||||
|
}
|
||||||
|
assert_raises(MockExpectationError, "create should not be called") do
|
||||||
|
mock.verify
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue