Skip to content

Commit

Permalink
check for slash. fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 15, 2016
1 parent 83f6aba commit f79839e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function authorizeForUser($user, $ability, $arguments = [])
*/
protected function parseAbilityAndArguments($ability, $arguments)
{
if (is_string($ability) && (! class_exists($ability))) {
if (is_string($ability) && strpos($ability, '\\') === false) {
return [$ability, $arguments];
}

Expand Down
7 changes: 5 additions & 2 deletions tests/Foundation/FoundationAuthorizesRequestsTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ public function test_policy_method_may_be_guessed_passing_model_instance()
$this->assertTrue($_SERVER['_test.authorizes.trait.policy']);
}

/**
* @group something
*/
public function test_policy_method_may_be_guessed_passing_class_name()
{
unset($_SERVER['_test.authorizes.trait.policy']);

$gate = $this->getBasicGate();

$gate->policy(FoundationAuthorizesRequestTestClass::class, FoundationAuthorizesRequestTestPolicy::class);
$gate->policy('\\'.FoundationAuthorizesRequestTestClass::class, FoundationAuthorizesRequestTestPolicy::class);

$response = (new FoundationTestAuthorizeTraitClass)->authorize(FoundationAuthorizesRequestTestClass::class);
$response = (new FoundationTestAuthorizeTraitClass)->authorize('\\'.FoundationAuthorizesRequestTestClass::class);

$this->assertInstanceOf(Response::class, $response);
$this->assertTrue($_SERVER['_test.authorizes.trait.policy']);
Expand Down

0 comments on commit f79839e

Please sign in to comment.