Skip to content

Commit

Permalink
Merge pull request #4 from laravel/5.2
Browse files Browse the repository at this point in the history
Fix scope nesting (laravel#13413)
  • Loading branch information
zither committed May 5, 2016
2 parents 52fc0b7 + a6ddacb commit 13ff6ac
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function buildCommand()
$command = $this->command.$redirect.$output.' 2>&1 &';
}

return $this->user ? 'sudo -u '.$this->user.' '.$command : $command;
return $this->user && ! windows_os() ? 'sudo -u '.$this->user.' -- sh -c \''.$command.'\'' : $command;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ protected function applyScope($scope, $builder)
*/
protected function shouldNestWheresForScope(QueryBuilder $query, $originalWhereCount)
{
return $originalWhereCount && count($query->wheres) > $originalWhereCount;
return count($query->wheres) > $originalWhereCount;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Mail/Transport/SparkPostTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
'content' => [
'html' => $message->getBody(),
'from' => $this->getFrom($message),
'reply_to' => $this->getReplyTo($message),
'subject' => $message->getSubject(),
],
],
Expand Down Expand Up @@ -106,6 +107,19 @@ protected function getFrom(Swift_Mime_Message $message)
}, array_keys($message->getFrom()), $message->getFrom())[0];
}

/**
* Get the 'reply_to' headers and format as required by SparkPost.
*
* @param Swift_Mime_Message $message
* @return string
*/
protected function getReplyTo(Swift_Mime_Message $message)
{
if (is_array($message->getReplyTo())) {
return current($message->getReplyTo()).' <'.key($message->getReplyTo()).'>';
}
}

/**
* Get the API key being used by the transport.
*
Expand Down
12 changes: 12 additions & 0 deletions tests/Auth/AuthGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ public function testLoginUsingIdFailure()
$this->assertFalse($guard->loginUsingId(11));
}

public function testOnceUsingIdSetsUser()
{
list($session, $provider, $request, $cookie) = $this->getMocks();
$guard = m::mock('Illuminate\Auth\SessionGuard', ['default', $provider, $session])->makePartial();

$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$guard->getProvider()->shouldReceive('retrieveById')->once()->with(10)->andReturn($user);
$guard->shouldReceive('setUser')->once()->with($user);

$this->assertTrue($guard->onceUsingId(10));
}

public function testOnceUsingIdFailure()
{
list($session, $provider, $request, $cookie) = $this->getMocks();
Expand Down
4 changes: 4 additions & 0 deletions tests/Database/DatabaseEloquentGlobalScopesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function testGlobalScopesWithOrWhereConditionsAreNested()
{
$model = new EloquentClosureGlobalScopesWithOrTestModel();

$query = $model->newQuery();
$this->assertEquals('select "email", "password" from "table" where ("email" = ? or "email" = ?) and "active" = ? order by "name" asc', $query->toSql());
$this->assertEquals(['taylor@gmail.com', 'someone@else.com', 1], $query->getBindings());

$query = $model->newQuery()->where('col1', 'val1')->orWhere('col2', 'val2');
$this->assertEquals('select "email", "password" from "table" where ("col1" = ? or "col2" = ?) and ("email" = ? or "email" = ?) and "active" = ? order by "name" asc', $query->toSql());
$this->assertEquals(['val1', 'val2', 'taylor@gmail.com', 'someone@else.com', 1], $query->getBindings());
Expand Down

0 comments on commit 13ff6ac

Please sign in to comment.