Commit f6610dbc authored by Mark Harding's avatar Mark Harding

(feat): do not allow appeal to be made unless just after initial_jury

1 merge request!100Epic/reporting and moderation
Pipeline #61688932 passed with stages
in 4 minutes and 53 seconds
......@@ -71,6 +71,10 @@ class Manager
*/
public function appeal(Appeal $appeal)
{
if ($appeal->getReport()->getState() !== 'initial_jury_decided') {
throw new NotAppealableException();
}
$added = $this->repository->add($appeal);
$this->notificationDelegate->onAction($appeal);
......
<?php
namespace Minds\Core\Reports\Appeals;
class NotAppealableException extends \Exception
{
protected $message = "This report is not able to be appealed";
}
......@@ -75,7 +75,7 @@ class ManagerSpec extends ObjectBehavior
->shouldBe(456);
}
function it_should_add_appeal_to_repository(Appeal $appeal)
function it_should_add_appeal_to_repository(Appeal $appeal, Report $report)
{
$this->repository->add($appeal)
->shouldBeCalled()
......@@ -84,8 +84,33 @@ class ManagerSpec extends ObjectBehavior
$this->notificationDelegate->onAction($appeal)
->shouldBeCalled();
$appeal->getReport()
->willReturn($report);
$report->getState()
->willReturn('initial_jury_decided');
$this->appeal($appeal)
->shouldBe(true);
}
function it_should_NOT_add_appeal_to_repository_if_not_been_to_initial_jury(Appeal $appeal, Report $report)
{
$this->repository->add($appeal)
->shouldNotBeCalled()
->willReturn(true);
$this->notificationDelegate->onAction($appeal)
->shouldNotBeCalled();
$appeal->getReport()
->willReturn($report);
$report->getState()
->willReturn('reported');
$this->shouldThrow('Minds\Core\Reports\Appeals\NotAppealableException')
->duringAppeal($appeal);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment