Skip to content

Commit f15aedb

Browse files
quirkeydefunkt
authored andcommitted
Tests for setting the resque-namespace through the url-string
1 parent 1840616 commit f15aedb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/resque.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ module Resque
3232
# or `Redis::Namespace`.
3333
def redis=(server)
3434
if server.respond_to? :split
35-
namespace = :resque
36-
3735
if server =~ /redis\:\/\//
3836
redis = Redis.connect(:url => server)
3937
else
@@ -42,6 +40,7 @@ def redis=(server)
4240
redis = Redis.new(:host => host, :port => port,
4341
:thread_safe => true, :db => db)
4442
end
43+
namespace ||= :resque
4544

4645
@redis = Redis::Namespace.new(namespace, :redis => redis)
4746
elsif server.respond_to? :namespace=

test/resque_test.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
Resque.push(:people, { 'name' => 'bob' })
99
Resque.push(:people, { 'name' => 'mark' })
1010
end
11+
12+
test "can set a namespace through a url-like string" do
13+
assert Resque.redis
14+
assert_equal :resque, Resque.redis.namespace
15+
Resque.redis = 'localhost:9736/namespace'
16+
assert_equal 'namespace', Resque.redis.namespace
17+
end
1118

1219
test "can put jobs on a queue" do
1320
assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
@@ -222,4 +229,4 @@
222229
test "decode bad json" do
223230
assert_nil Resque.decode("{\"error\":\"Module not found \\u002\"}")
224231
end
225-
end
232+
end

0 commit comments

Comments
 (0)