Skip to content

Commit

Permalink
fix: loosing the second facet at the end of the url on redirection (#…
Browse files Browse the repository at this point in the history
…8307)

* fix: loosing the second facet at the end of the url on redirection

* use is() instead of like() and unlike()
  • Loading branch information
jnsereko authored Apr 13, 2023
1 parent 76dc037 commit 28aa93d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3060,6 +3060,7 @@ sub display_tag ($request_ref) {
}

if (defined $request_ref->{groupby_tagtype}) {
$request_ref->{current_link} .= "/" . $tag_type_plural{$request_ref->{groupby_tagtype}}{$lc};
$request_ref->{world_current_link} .= "/" . $tag_type_plural{$request_ref->{groupby_tagtype}}{$lc};
}

Expand Down
56 changes: 56 additions & 0 deletions tests/unit/display.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use Modern::Perl '2017';
use utf8;

use Test::More;
use Test::MockModule;
use Log::Any::Adapter 'TAP';

use ProductOpener::Display qw/:all/;
Expand Down Expand Up @@ -150,4 +151,59 @@ $product_ref = {
$expected = lang('to_do_status') . separator_before_colon($lc) . q{:};
like(display_field($product_ref, 'states'), qr/$expected/);

# should not loose the second facet at the end of the url on redirection
my $facets_ref = {
'tagtype' => 'categories',
'groupby_tagtype' => 'data_quality',
'tagid' => 'en:bread'
};

my $apache_util_module = Test::MockModule->new('Apache2::RequestUtil');
$apache_util_module->mock(
'request',
sub {
# Return a mock Apache request object
my $r = {};
bless $r, 'Apache2::RequestRec';

return $r;
}
);

my $request_rec_module = Test::MockModule->new('Apache2::RequestRec');
$request_rec_module->mock(
'rflush',
sub {
# Do nothing, am just mocking the method
}
);

$request_rec_module->mock(
'status',
sub {
# Do nothing, am just mocking the method
}
);

$request_rec_module->mock(
'headers_out',
sub {
# Do nothing, am just mocking the method

}
);

my $display_module = Test::MockModule->new('ProductOpener::Display');
$display_module->mock(
'redirect_to_url',
sub {
# Do nothing, am just mocking the method
}
);

display_tag($facets_ref);

is($facets_ref->{'current_link'}, '/category/breads/data-quality');
is($facets_ref->{'redirect'}, '/category/breads/data-quality');

done_testing();

0 comments on commit 28aa93d

Please sign in to comment.