Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Blamer no longer blames comments that already have an author.

  • Loading branch information...
commit 56a32544037cfe387785be4e75da02fae985fe66 1 parent 8a8c222
@merk merk authored
View
2  EventListener/CommentBlamerListener.php
@@ -76,7 +76,7 @@ public function blame(CommentEvent $event)
return;
}
- if ($this->securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
+ if (null === $comment->getAuthor() && $this->securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
$comment->setAuthor($this->securityContext->getToken()->getUser());
}
}
View
6 Tests/EventListener/CommentBlamerListenerTest.php
@@ -61,13 +61,13 @@ public function testEditingCommentDoesNotChangeBlame()
{
$comment = $this->getSignedComment();
$comment->expects($this->never())->method('setAuthor');
+ $comment->expects($this->once())->method('getAuthor')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
$event = new CommentEvent($comment);
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
- $token->expects($this->once())->method('getUser')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
$securityContext = $this->getSecurityContext();
- $securityContext->expects($this->once())->method('isGranted')->with('IS_AUTHENTICATED_FULLY')->will($this->returnValue(true));
- $securityContext->expects($this->exactly(2))->method('getToken')->will($this->returnValue($token));
+ $securityContext->expects($this->never())->method('isGranted');
+ $securityContext->expects($this->once())->method('getToken')->will($this->returnValue($token));
$listener = new CommentBlamerListener($securityContext);
$listener->blame($event);

0 comments on commit 56a3254

Please sign in to comment.
Something went wrong with that request. Please try again.