Skip to content

Commit

Permalink
Merge pull request #495 from tighten/ajm/exclude-rejected-conferences
Browse files Browse the repository at this point in the history
Exclude rejected conferences from search index
  • Loading branch information
andrewmile authored Dec 15, 2023
2 parents f30753a + b93a052 commit ea4af41
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Models/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/Feature/ConferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit ea4af41

Please sign in to comment.