Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tests for setting the resque-namespace through the url-string

  • Loading branch information...
commit f15aedb075103cf4750134dee7019757bf4c7136 1 parent 1840616
@quirkey quirkey authored defunkt committed
Showing with 9 additions and 3 deletions.
  1. +1 −2  lib/resque.rb
  2. +8 −1 test/resque_test.rb
View
3  lib/resque.rb
@@ -32,8 +32,6 @@ module Resque
# or `Redis::Namespace`.
def redis=(server)
if server.respond_to? :split
- namespace = :resque
-
if server =~ /redis\:\/\//
redis = Redis.connect(:url => server)
else
@@ -42,6 +40,7 @@ def redis=(server)
redis = Redis.new(:host => host, :port => port,
:thread_safe => true, :db => db)
end
+ namespace ||= :resque
@redis = Redis::Namespace.new(namespace, :redis => redis)
elsif server.respond_to? :namespace=
View
9 test/resque_test.rb
@@ -8,6 +8,13 @@
Resque.push(:people, { 'name' => 'bob' })
Resque.push(:people, { 'name' => 'mark' })
end
+
+ test "can set a namespace through a url-like string" do
+ assert Resque.redis
+ assert_equal :resque, Resque.redis.namespace
+ Resque.redis = 'localhost:9736/namespace'
+ assert_equal 'namespace', Resque.redis.namespace
+ end
test "can put jobs on a queue" do
assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
@@ -222,4 +229,4 @@
test "decode bad json" do
assert_nil Resque.decode("{\"error\":\"Module not found \\u002\"}")
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.