Skip to content

Commit 5aed917

Browse files
committed
1 parent a8322cd commit 5aed917

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/Resque/Redis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Resque_Redis
9898
*/
9999
public static function prefix($namespace)
100100
{
101-
if (strpos($namespace, ':') === false) {
101+
if (substr($namespace, -1) !== ':') {
102102
$namespace .= ':';
103103
}
104104
self::$defaultNamespace = $namespace;

test/Resque/Tests/JobTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,21 @@ public function testJobWithTearDownCallbackFiresTearDown()
166166

167167
$this->assertTrue(Test_Job_With_TearDown::$called);
168168
}
169-
169+
170+
public function testNamespaceNaming() {
171+
$fixture = array(
172+
array('test' => 'more:than:one:with:', 'assertValue' => 'more:than:one:with:'),
173+
array('test' => 'more:than:one:without', 'assertValue' => 'more:than:one:without:'),
174+
array('test' => 'resque', 'assertValue' => 'resque:'),
175+
array('test' => 'resque:', 'assertValue' => 'resque:'),
176+
);
177+
178+
foreach($fixture as $item) {
179+
Resque_Redis::prefix($item['test']);
180+
$this->assertEquals(Resque_Redis::getPrefix(), $item['assertValue']);
181+
}
182+
}
183+
170184
public function testJobWithNamespace()
171185
{
172186
Resque_Redis::prefix('php');
@@ -176,7 +190,7 @@ public function testJobWithNamespace()
176190

177191
$this->assertEquals(Resque::queues(), array('jobs'));
178192
$this->assertEquals(Resque::size($queue), 1);
179-
193+
180194
Resque_Redis::prefix('resque');
181195
$this->assertEquals(Resque::size($queue), 0);
182196
}

0 commit comments

Comments
 (0)