Fixes a bug that would cause non-editable variables on the front-end to throw a validation error

This commit is contained in:
Dane Everitt 2018-02-15 20:58:51 -06:00
parent e2cdb3b4b1
commit 8e1aa15dba
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 14 additions and 3 deletions

View file

@ -128,9 +128,12 @@ class VariableValidatorServiceTest extends TestCase
$messages = $exception->validator->getMessageBag()->all();
$this->assertNotEmpty($messages);
$this->assertSame(4, count($messages));
$this->assertSame(2, count($messages));
for ($i = 0; $i < 4; $i++) {
// We only expect to get the first two variables form the getVariableCollection
// function here since those are the only two that are editable, and the others
// should be discarded and not validated.
for ($i = 0; $i < 2; $i++) {
$this->assertSame(trans('validation.required', [
'attribute' => trans('validation.internal.variable_value', ['env' => $variables[$i]->name]),
]), $messages[$i]);
@ -148,8 +151,8 @@ class VariableValidatorServiceTest extends TestCase
return collect(
[
factory(EggVariable::class)->states('editable', 'viewable')->make(),
factory(EggVariable::class)->states('viewable')->make(),
factory(EggVariable::class)->states('editable')->make(),
factory(EggVariable::class)->states('viewable')->make(),
factory(EggVariable::class)->make(),
]
);