diff --git a/app/Models/Conference.php b/app/Models/Conference.php index b6a27587..219a1faf 100644 --- a/app/Models/Conference.php +++ b/app/Models/Conference.php @@ -265,7 +265,7 @@ public function scopeWhereDismissedBy($query, $user) public function shouldBeSearchable(): bool { - return $this->starts_at > Carbon::now(); + return $this->starts_at > Carbon::now() && ! $this->isRejected(); } /** diff --git a/tests/Feature/ConferenceTest.php b/tests/Feature/ConferenceTest.php index 18a2b2d8..b8115328 100644 --- a/tests/Feature/ConferenceTest.php +++ b/tests/Feature/ConferenceTest.php @@ -1227,4 +1227,24 @@ public function searching_conferences_by_name(): void $this->assertContains($conferenceA->id, $results->pluck('id')); $this->assertNotContains($conferenceB->id, $results->pluck('id')); } + + /** @test */ + public function past_conferences_are_not_searchable(): void + { + $conferenceA = Conference::factory()->dates(now()->subDay())->create(); + $conferenceB = Conference::factory()->dates(now()->addDay())->create(); + + $this->assertFalse($conferenceA->shouldBeSearchable()); + $this->assertTrue($conferenceB->shouldBeSearchable()); + } + + /** @test */ + public function rejected_conferences_are_not_searchable(): void + { + $conferenceA = Conference::factory()->create(['rejected_at' => now()]); + $conferenceB = Conference::factory()->create(['rejected_at' => null]); + + $this->assertFalse($conferenceA->shouldBeSearchable()); + $this->assertTrue($conferenceB->shouldBeSearchable()); + } }