Skip to content

Commit

Permalink
Merge pull request #293 from neontribe/1.6/1336-bug-content-of-bad-co…
Browse files Browse the repository at this point in the history
…de-problem-error-message

1.6/1336 bug content of bad code problem error message
  • Loading branch information
charlesstrange2 authored Aug 15, 2019
2 parents 33a95a8 + e1beb2b commit 11fe9bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function (Voucher $voucher) use ($bundle, &$errors) {
// Check if the voucher is disbursed, because we can't change those.
if ($voucher->bundle && $voucher->bundle->disbursed_at !== null) {
// Throw it into an error.
$errors["codes"][] = $voucher->code;
$errors["disbursed"][] = $voucher->code;
} else {
// Change its bundle
$voucher->bundle()->associate($bundle)->save();
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/Store/BundleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,16 @@ public function redirectAfterRequest($errors, $successRoute, $failRoute)
}
break;
case "transition":
$messages[] = "Transition problem with: " . join(', ', $values);
$messages[] = "Voucher state change problem with: " . join(', ', $values);
break;
case "codes":
$messages[] = "Bad code problem with: " . join(', ', $values);
$messages[] = "These codes are invalid: " . join(', ', $values);
break;
case "disbursed":
$messages[] = "These vouchers have been given out: " . join(', ', $values);
break;
case "foreign":
$messages[] = "Action denied on a foreign voucher: " . join(', ', $values);
$messages[] = "Action denied on a different bundle: " . join(', ', $values);
break;
case "empty":
if ($values) {
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Models/BundleModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public function testItCannotAlterTheBundleToIncludeADisbursedVoucher()
$errors = $disbursedBundle->alterVouchers($vs, [], null);

// See errors
$this->assertArrayHasKey("codes", $errors);
$this->assertArraySubset($vs->pluck("code")->toArray(), $errors["codes"]);
$this->assertArrayHasKey("disbursed", $errors);
$this->assertArraySubset($vs->pluck("code")->toArray(), $errors["disbursed"]);

// See it has the vouchers still
$this->assertEquals(3, $disbursedBundle->vouchers()->count());
Expand All @@ -165,8 +165,8 @@ public function testItCannotAlterTheBundleToIncludeADisbursedVoucher()
$errors = $this->bundle->alterVouchers($vs, [], $this->bundle);

// See errors.
$this->assertArrayHasKey("codes", $errors);
$this->assertArraySubset($vs->pluck("code")->toArray(), $errors["codes"]);
$this->assertArrayHasKey("disbursed", $errors);
$this->assertArraySubset($vs->pluck("code")->toArray(), $errors["disbursed"]);

// See it has the vouchers still.
$this->assertEquals(3, $disbursedBundle->vouchers()->count());
Expand Down

0 comments on commit 11fe9bb

Please sign in to comment.