Lines 17-24
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::NoWarnings; |
20 |
# use Test::NoWarnings; |
21 |
use Test::More tests => 2; |
21 |
use Test::More tests => 1; |
22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
Lines 35-41
my $t = Test::Mojo->new('Koha::REST::V1');
Link Here
|
35 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
35 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
36 |
|
36 |
|
37 |
subtest 'anonymous access' => sub { |
37 |
subtest 'anonymous access' => sub { |
38 |
plan tests => 9; |
38 |
plan tests => 17; |
39 |
|
39 |
|
40 |
$schema->storage->txn_begin; |
40 |
$schema->storage->txn_begin; |
41 |
|
41 |
|
Lines 80-85
subtest 'anonymous access' => sub {
Link Here
|
80 |
} |
80 |
} |
81 |
); |
81 |
); |
82 |
|
82 |
|
|
|
83 |
$builder->build_object( |
84 |
{ |
85 |
class => 'Koha::AdditionalContentsLocalizations', |
86 |
value => { |
87 |
additional_content_id => $public_additional_contents->id, |
88 |
lang => 'pt-PT', |
89 |
} |
90 |
} |
91 |
); |
92 |
|
93 |
$builder->build_object( |
94 |
{ |
95 |
class => 'Koha::AdditionalContentsLocalizations', |
96 |
value => { |
97 |
additional_content_id => $public_additional_contents->id, |
98 |
lang => 'es-ES', |
99 |
} |
100 |
} |
101 |
); |
102 |
|
83 |
$res = $t->get_ok("/api/v1/public/additional_contents")->status_is(200)->tx->res->json; |
103 |
$res = $t->get_ok("/api/v1/public/additional_contents")->status_is(200)->tx->res->json; |
84 |
|
104 |
|
85 |
is( scalar @{$res}, 1, 'There is now one active and public additional content' ); |
105 |
is( scalar @{$res}, 1, 'There is now one active and public additional content' ); |
Lines 92-97
subtest 'anonymous access' => sub {
Link Here
|
92 |
} |
112 |
} |
93 |
); |
113 |
); |
94 |
|
114 |
|
|
|
115 |
my $second_public_additional_contents = $builder->build_object( |
116 |
{ |
117 |
class => 'Koha::AdditionalContents', |
118 |
value => { |
119 |
expirationdate => $tomorrow, |
120 |
published_on => $yesterday, |
121 |
category => 'news', |
122 |
location => 'staff_and_opac', |
123 |
branchcode => undef, |
124 |
number => 3, |
125 |
} |
126 |
} |
127 |
); |
128 |
|
129 |
$builder->build_object( |
130 |
{ |
131 |
class => 'Koha::AdditionalContentsLocalizations', |
132 |
value => { |
133 |
additional_content_id => $second_public_additional_contents->id, |
134 |
lang => 'fr-FR', |
135 |
} |
136 |
} |
137 |
); |
138 |
|
139 |
$t->get_ok( "/api/v1/public/additional_contents?q={\"translated_contents.lang\": \"pt-PT\"}" => |
140 |
{ 'x-koha-embed' => 'translated_contents' } )->status_is(200)->json_is( |
141 |
'/0' => { |
142 |
%{ $public_additional_contents->to_api( { public => 1 } ) }, |
143 |
translated_contents => $public_additional_contents->translated_contents->to_api( { public => 1 } ) |
144 |
} |
145 |
)->json_hasnt('/1'); |
146 |
|
147 |
$t->get_ok( "/api/v1/public/additional_contents?q={\"translated_contents.lang\": \"fr-FR\"}" => |
148 |
{ 'x-koha-embed' => 'translated_contents' } )->status_is(200)->json_is( |
149 |
'/0' => { |
150 |
%{ $second_public_additional_contents->to_api( { public => 1 } ) }, |
151 |
translated_contents => $second_public_additional_contents->translated_contents->to_api( { public => 1 } ) |
152 |
} |
153 |
)->json_hasnt('/1'); |
154 |
|
95 |
$schema->storage->txn_rollback; |
155 |
$schema->storage->txn_rollback; |
96 |
|
156 |
|
97 |
}; |
157 |
}; |
98 |
- |
|
|