Do not follow redirects when asserting no session errors

This commit is contained in:
Christopher C. Wells 2021-03-30 15:36:39 -07:00 committed by Christopher Charbonneau Wells
parent a686e8036b
commit f9cb622d92
2 changed files with 3 additions and 9 deletions

View File

@ -45,8 +45,7 @@ abstract class HttpControllerTestCase extends LoggedInTestCase
$response->assertOk();
$instance = $this->factory()->make();
$store_url = action([$this->class(), 'store']);
$response = $this->followingRedirects()->post($store_url, $instance->toArray());
$response->assertOk();
$response = $this->post($store_url, $instance->toArray());
$response->assertSessionHasNoErrors();
}
@ -68,10 +67,8 @@ abstract class HttpControllerTestCase extends LoggedInTestCase
$new_instance = $this->factory()->make();
$put_url = action([$this->class(), 'update'], [$this->routeKey() => $instance]);
$response = $this->followingRedirects()->put($put_url, $new_instance->toArray());
$response->assertOk();
$response = $this->put($put_url, $new_instance->toArray());
$response->assertSessionHasNoErrors();
$response->assertViewHas($this->routeKey());
}
public function testCanDeleteInstance(): void

View File

@ -2,9 +2,7 @@
namespace Tests\Feature\Http\Controllers;
use App\Http\Controllers\GoalController;
use App\Http\Controllers\JournalEntryController;
use App\Models\Goal;
use App\Models\JournalEntry;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Model;
@ -69,8 +67,7 @@ class JournalEntryControllerTest extends HttpControllerTestCase
$response->assertOk();
$instance = $this->factory()->make();
$store_url = action([$this->class(), 'storeFromNutrients']);
$response = $this->followingRedirects()->post($store_url, $instance->toArray());
$response->assertOk();
$response = $this->post($store_url, $instance->toArray());
$response->assertSessionHasNoErrors();
}