Skip to content

Commit

Permalink
fix: Allow searching of CID within feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
CalumTowers committed Aug 29, 2024
1 parent ff9c17e commit f0a8443
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/Http/Controllers/Mship/Feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ public function postFeedback(Form $form, Request $request)
->withSuccess('Your feedback has been recorded. Thank you!');
}

public function getUserSearch($name, Request $request)
public function getUserSearch($search, Request $request)
{
$matches = Account::whereRaw("CONCAT(`name_first`, ' ',`name_last`) LIKE \"%".$name.'%"')
->where('id', '!=', \Auth::user()->id)
$matches = Account::where(function ($query) use ($search) {
return $query->whereRaw("CONCAT(`name_first`, ' ',`name_last`) LIKE \"%".$search.'%"')
->orWhere('id', $search);
})->where('id', '!=', \Auth::user()->id)
->limit(5)
->with(['states'])
->get(['id', 'name_first', 'name_last']);
Expand Down
13 changes: 12 additions & 1 deletion tests/Feature/Account/Feedback/FeedbackUserSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setUp(): void
}

/** @test */
public function testItReturnsAnotherUser()
public function testItReturnsAnotherUserByName()
{
$searchQuery = $this->actingAs($this->user)
->get(route('mship.feedback.usersearch', $this->otherUser->real_name))
Expand All @@ -30,6 +30,17 @@ public function testItReturnsAnotherUser()
$this->assertStringContainsString((string) $this->otherUser->id, $searchQuery);
}

/** @test */
public function testItReturnsAnotherUserById()
{
$searchQuery = $this->actingAs($this->user)
->get(route('mship.feedback.usersearch', $this->otherUser->id))
->getContent();

$this->assertStringContainsString(e($this->otherUser->real_name), $searchQuery);
$this->assertStringContainsString((string) $this->otherUser->id, $searchQuery);
}

/** @test */
public function testItDoesNotReturnCurrentUser()
{
Expand Down

0 comments on commit f0a8443

Please sign in to comment.