write tests; remove pending_notify
This commit is contained in:
parent
94557a817f
commit
c106d04ba8
3 changed files with 142 additions and 6 deletions
|
@ -24,7 +24,6 @@ public function up()
|
||||||
$table->string('image')->nullable();
|
$table->string('image')->nullable();
|
||||||
$table->timestamp('opened', 6)->nullable();
|
$table->timestamp('opened', 6)->nullable();
|
||||||
$table->boolean('hold_member_updates')->default(true);
|
$table->boolean('hold_member_updates')->default(true);
|
||||||
$table->boolean('notify_pending')->default(true);
|
|
||||||
$table->string('sort_by')->default('country');
|
$table->string('sort_by')->default('country');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
<x-form.file name="image" />
|
<x-form.file name="image" />
|
||||||
<x-form.date name="date_opened" :label="'Date opened:'" />
|
<x-form.date name="date_opened" :label="'Date opened:'" />
|
||||||
<x-form.checkbox name="hold_member_updates" :label="'Hold member updates?'" />
|
<x-form.checkbox name="hold_member_updates" :label="'Hold member updates?'" />
|
||||||
<x-form.checkbox name="notify_pending" :label="'Notify when you have pending members?'" />
|
|
||||||
|
|
||||||
<x-form.buttons />
|
<x-form.buttons />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
use App\Models\Collective;
|
use App\Models\Collective;
|
||||||
|
use App\Models\Owned;
|
||||||
use function Pest\Faker\faker;
|
use function Pest\Faker\faker;
|
||||||
|
|
||||||
uses()->group('owned', 'admin');
|
uses()->group('owned', 'admin');
|
||||||
|
@ -8,10 +10,14 @@
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->user = Collective::first();
|
$this->user = Collective::first();
|
||||||
$this->request = [
|
$this->request = [
|
||||||
'categories' => [rand(1, 57), rand(1, 57), rand(1, 57)],
|
'categories' => [rand(1, 57), rand(1, 57), rand(1, 57)],
|
||||||
'url' => faker()->url,
|
'subject' => faker()->word,
|
||||||
'subject' => faker()->word,
|
'status' => 'current',
|
||||||
'approved' => faker()->boolean,
|
'slug' => faker()->slug(2),
|
||||||
|
'title' => faker()->sentence(),
|
||||||
|
'date_opened' => faker()->dateTimeThisMonth(),
|
||||||
|
'hold_member_updates' => faker()->boolean(),
|
||||||
|
'notify_pending' => faker()->boolean(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,3 +32,135 @@
|
||||||
|
|
||||||
$response->assertRedirect('/fanatic/login');
|
$response->assertRedirect('/fanatic/login');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('validates correct request', function () {
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertValid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails missing categories', function () {
|
||||||
|
unset($this->request['categories']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-array categories', function () {
|
||||||
|
$this->request['categories'] = 'This is not an array.';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails empty categories array', function () {
|
||||||
|
$this->request['categories'] = [];
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-numeric category item', function () {
|
||||||
|
$this->request['categories'][] = 'a';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-existant category', function () {
|
||||||
|
$invalidCat = (Category::all()->count()) + 10;
|
||||||
|
$this->request['categories'][] = $invalidCat;
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails missing subject', function () {
|
||||||
|
unset($this->request['subject']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-string subject', function () {
|
||||||
|
$this->request['subject'] = 39502;
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails missing status', function () {
|
||||||
|
unset($this->request['status']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-valid status', function () {
|
||||||
|
$this->request['status'] = 'This is not a correct status.';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails missing slug', function () {
|
||||||
|
unset($this->request['slug']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-valid slug format', function () {
|
||||||
|
$this->request['slug'] = 'This is not a valid slug.';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows null title', function () {
|
||||||
|
unset($this->request['title']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertValid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-string title', function () {
|
||||||
|
$this->request['title'] = 494920;
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows null date_opened', function () {
|
||||||
|
unset($this->request['date_opened']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertValid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-date date_opened', function () {
|
||||||
|
$this->request['date_opened'] = 'This is not a date.';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows null hold_member_updates', function () {
|
||||||
|
unset($this->request['hold_member_updates']);
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertValid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails non-bool hold_member_updates', function () {
|
||||||
|
$this->request['holds_member_updates'] = 'This is not a boolean.';
|
||||||
|
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
|
||||||
|
|
||||||
|
$response->assertInvalid();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves model to database', function () {
|
||||||
|
$owned = Owned::factory()->create();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('owned', ['id' => $owned->id]);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue