Skip to content

Commit

Permalink
Merge pull request #83 from scify/master
Browse files Browse the repository at this point in the history
Fixed test
  • Loading branch information
PavlosIsaris authored Oct 4, 2024
2 parents c863b34 + 29d1d32 commit 53f10d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 5 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Random\RandomException;

class UserFactory extends Factory {
protected $model = User::class;

/**
* @throws RandomException
*/
public function definition() {
return [
'id' => $this->faker->unique()->numberBetween(1, 10000),
'nickname' => $this->faker->name,
'avatar' => $this->faker->imageUrl(),
'email' => $this->faker->unique()->safeEmail,
Expand Down
2 changes: 1 addition & 1 deletion resources/views/gamification/next-step.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class="btn btn-light w-100 mb-2 text-left">
@endforeach
</div>
</div>
@else
@elseif($nextStepVM->projects->count() == 1)
<a href="{{route("project.landing-page", $questionnaire->projects->get(0)->slug) . "?open=1"}}"
class="btn btn-primary btn-lg nextStepActionBtn">{{ __("badges_messages.contribute") }}</a>
@endif
Expand Down
12 changes: 4 additions & 8 deletions tests/Feature/Controllers/CrowdSourcingProjectControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
use App\Models\UserRole;
use App\Repository\CrowdSourcingProject\CrowdSourcingProjectRepository;
use Faker\Factory as Faker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class CrowdSourcingProjectControllerTest extends TestCase {
use RefreshDatabase;

protected $seed = true;
protected CrowdSourcingProjectRepository $crowdSourcingProjectRepository;

protected function setUp(): void {
Expand Down Expand Up @@ -299,16 +295,16 @@ public function guestCannotStoreProject() {
/**
* @test
*/
public function authenticatedUserCannotStoreProject() {
public function nonAdminUserCannotStoreProject() {
$user = User::factory()->create();
$this->actingAs($user);
$this->be($user);

$response = $this->withoutMiddleware(VerifyCsrfToken::class) // Disable CSRF only
->post(route('projects.store'), [
'name' => 'Test Project',
'name' => 'Test Project ' . rand(1, 100),
'description' => 'Test Description',
'status_id' => 1,
'slug' => 'test-project',
'slug' => 'test-project-' . rand(1, 100),
'language_id' => 1,
]);

Expand Down

0 comments on commit 53f10d9

Please sign in to comment.