Skip to content

Commit

Permalink
Merge pull request chrisboulton#235 from magnusp/master
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisboulton committed Mar 12, 2015
2 parents a8322cd + 5aed917 commit eb7ab0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Resque/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Resque_Redis
*/
public static function prefix($namespace)
{
if (strpos($namespace, ':') === false) {
if (substr($namespace, -1) !== ':') {
$namespace .= ':';
}
self::$defaultNamespace = $namespace;
Expand Down
18 changes: 16 additions & 2 deletions test/Resque/Tests/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,21 @@ public function testJobWithTearDownCallbackFiresTearDown()

$this->assertTrue(Test_Job_With_TearDown::$called);
}


public function testNamespaceNaming() {
$fixture = array(
array('test' => 'more:than:one:with:', 'assertValue' => 'more:than:one:with:'),
array('test' => 'more:than:one:without', 'assertValue' => 'more:than:one:without:'),
array('test' => 'resque', 'assertValue' => 'resque:'),
array('test' => 'resque:', 'assertValue' => 'resque:'),
);

foreach($fixture as $item) {
Resque_Redis::prefix($item['test']);
$this->assertEquals(Resque_Redis::getPrefix(), $item['assertValue']);
}
}

public function testJobWithNamespace()
{
Resque_Redis::prefix('php');
Expand All @@ -176,7 +190,7 @@ public function testJobWithNamespace()

$this->assertEquals(Resque::queues(), array('jobs'));
$this->assertEquals(Resque::size($queue), 1);

Resque_Redis::prefix('resque');
$this->assertEquals(Resque::size($queue), 0);
}
Expand Down

0 comments on commit eb7ab0c

Please sign in to comment.