Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

$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();