Skip to content

Commit

Permalink
Merge pull request #30 from pinkary-project/fix/pinned-questions
Browse files Browse the repository at this point in the history
Only display `pinned` label on `profile.show`
  • Loading branch information
nunomaduro authored Mar 22, 2024
2 parents 9b3fe12 + c45f8d6 commit cdedea5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Livewire/Questions/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function render(Request $request): View
$query->whereNotNull('answer');
})
->orderByDesc('pinned')
->orderByDesc('updated_at')
->orderByDesc('answered_at')
->simplePaginate($this->perPage),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/questions/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class="ml-1 mt-0.5 h-4 w-4 flex-shrink-0"
</div>
</a>
@endif
@if ($question->pinned)
@if ($question->pinned && request()->routeIs('profile.show'))
<div class="mb-2 flex items-center space-x-1 px-4 text-sm focus:outline-none">
<x-icons.pin class="h-4 w-4 text-slate-400" />
<span class="text-slate-400">Pinned</span>
Expand Down
17 changes: 17 additions & 0 deletions tests/Unit/Livewire/Questions/ShowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,20 @@

$component->assertForbidden();
});

test('display pinned label only on profile.show route', function () {
$user = User::factory()->create();

Question::factory()->create([
'to_id' => $user->id,
'pinned' => true,
]);

$response = $this->actingAs($user)->get(route('profile.show', $user));

$response->assertSee('Pinned');

$response = $this->actingAs($user)->get(route('home'));

$response->assertDontSee('Pinned');
});

0 comments on commit cdedea5

Please sign in to comment.