Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland committed Jan 13, 2025
1 parent c6423ae commit 5eeeec8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Http/Actions/BuildAchievementOfTheWeekDataAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function execute(): ?EventAchievementData
->with(['achievement.game', 'sourceAchievement.game'])
->first();

if (!$achievementOfTheWeek) {
if (!$achievementOfTheWeek?->source_achievement_id) {
return null;
}

Expand Down
35 changes: 35 additions & 0 deletions tests/Feature/Http/Controllers/HomeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,41 @@ public function testItCorrectlySendsAchievementOfTheWeekProps(): void
);
}

public function testItHandlesAotwEventAchievementsWithoutSourceAchievement(): void
{
// Arrange
System::factory()->create(['ID' => System::Events]);
$eventGame = Game::factory()->create([
'ConsoleID' => System::Events,
'Title' => 'Achievement of the Week',
'ForumTopicId' => 14029,
]);

$eventAchievement = Achievement::factory()->published()->create(['GameID' => $eventGame->id]);

EventAchievement::create([
'achievement_id' => $eventAchievement->id,
'source_achievement_id' => null, // !! explicitly set to null
'active_from' => Carbon::now()->subDays(3),
'active_until' => Carbon::now()->addDays(3),
]);
Event::create([
'legacy_game_id' => $eventGame->id,
'slug' => 'foo',
'active_from' => Carbon::now()->subDays(3),
'active_until' => Carbon::now()->addDays(3),
]);

// Act
$response = $this->get(route('home'));

// Assert
$response->assertOk();
$response->assertInertia(fn (Assert $page) => $page
->where('achievementOfTheWeek', null)
);
}

public function testItCorrectlySendsRecentNewsProps(): void
{
// Arrange
Expand Down

0 comments on commit 5eeeec8

Please sign in to comment.