Skip to content

Commit

Permalink
make route /katalog to use NewCatalogController + add new route /kata…
Browse files Browse the repository at this point in the history
…log-old
  • Loading branch information
igor-kamil committed Nov 21, 2024
1 parent add48ff commit 5a858bc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 31 deletions.
3 changes: 0 additions & 3 deletions app/Http/Middleware/RedirectLegacyCatalogRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class RedirectLegacyCatalogRequest
*/
public function handle(Request $request, Closure $next): Response
{
if (!Experiment::is('new-catalog')) {
return $next($request);
}

if ($request->getQueryString() === null || !$this->isLegacyCatalogRequest($request)) {
return $next($request);
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Middleware/SetExperiments.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class SetExperiments
public function handle(Request $request, Closure $next): Response
{
$request->whenFilled('experiment', function ($experiment) {
if ($experiment === 'new-catalog' || $experiment === 'new-katalog') {
return Experiment::set('new-catalog');
}
// if ($experiment === 'new-catalog' || $experiment === 'new-katalog') {
// return Experiment::set('new-catalog');
// }
});

return $next($request);
Expand Down
5 changes: 1 addition & 4 deletions resources/views/components/searchbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
'class' => 'navbar-form right-inner-addon ukraine',
]) !!}
<i class="fa fa-search"></i>
@php
$search_value = Experiment::is('new-catalog') ? request()->get('q') : request()->get('search')
@endphp
{!! Form::text('search', $search_value, [
{!! Form::text('search', request()->get('q'), [
'class' => 'form-control',
'placeholder' => utrans('master.search_placeholder'),
'id' => 'search',
Expand Down
13 changes: 5 additions & 8 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,14 @@ function()

Route::get('patternlib', [PatternlibController::class, 'getIndex'])->name('frontend.patternlib.index');

Route::get('katalog', function (HttpRequest $request) {
if (Experiment::is('new-catalog')) {
return app(NewCatalogController::class)->index($request);
}

return app(CatalogController::class)->getIndex();
})
Route::get('katalog', [NewCatalogController::class, 'index'])
->middleware(RedirectLegacyCatalogRequest::class)
->name('frontend.catalog.index');

Route::resource('katalog-new', NewCatalogController::class)->names('frontend.catalog-new'); // TODO remove after release
Route::get('katalog-old', [CatalogController::class, 'getIndex'])
->name('frontend.catalog.old');

// Route::resource('katalog-new', NewCatalogController::class)->names('frontend.catalog-new'); // TODO remove after release

Route::get('katalog/suggestions', [CatalogController::class, 'getSuggestions'])->name('frontend.catalog.suggestions');
Route::get('katalog/random', [CatalogController::class, 'getRandom'])->name('frontend.catalog.random');
Expand Down
6 changes: 0 additions & 6 deletions tests/Feature/RedirectLegacyCatalogRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

class RedirectLegacyCatalogRequestTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

Experiment::set('new-catalog');
}

public function test_redirects_to_new_catalog_url(): void
{
Expand Down
7 changes: 0 additions & 7 deletions tests/NewCatalogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

namespace Tests\Views\Frontend;

use App\Facades\Experiment;
use Tests\TestCase;

class NewCatalogTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

Experiment::set('new-catalog');
}

public function test_title_is_based_on_filters()
{
Expand Down
6 changes: 6 additions & 0 deletions tests/Views/Frontend/CatalogViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ public function testGetRandom()
$response = $this->get('/katalog/random');
$response->assertStatus(200);
}

// test the legacy catalog - should be removed after no longer needed/supported
public function testOldCatalog() {
$response = $this->get('/katalog-old');
$response->assertStatus(200);
}
}

0 comments on commit 5a858bc

Please sign in to comment.