Skip to content

Commit

Permalink
Filter out non public treebanks from list
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Sedlák committed Aug 24, 2015
1 parent 7e9a407 commit a9a854b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/PMLTQ/Server/Controller/Treebank.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use PMLTQ::Server::Validation;
sub list {
my $c = shift;

$c->mandel->collection('treebank')->all(sub {
$c->mandel->collection('treebank')->search({ public => Mojo::JSON->true })->all(sub {
my($collection, $err, $treebanks) = @_;

$c->render(json => [ map {
Expand Down
11 changes: 10 additions & 1 deletion t/api_treebank.t
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ ok ($treebanks_url, 'Treebanks url');
$t->get_ok($treebanks_url)
->status_is(200);

is(scalar(@{$t->tx->res->json}), 1, 'Returned one treebank');
$t->json_is("/0/$_", $tb->$_) for (qw/id name title description homepage/);
#$t->json_is('/0/url', $t->app->url_for('treebank', treebank => $tb->name));

# Set public to false
$tb->public(Mojo::JSON->false);
$tb->save();

$t->get_ok($treebanks_url)
->status_is(200);

is(scalar(@{$t->tx->res->json}), 0, 'Returned no treebank');

ok $t->app->routes->find('treebank'), 'Single treebank route exists';

Expand Down
4 changes: 2 additions & 2 deletions t/bootstrap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ sub test_treebank {
database => 'test',
username => 'postgres',
password => '',
public => 1,
anonaccess => 1,
public => Mojo::JSON->true,
anonaccess => Mojo::JSON->true,
data_sources => {
adata => File::Spec->catdir('pdt20_mini', 'data'),
tdata => File::Spec->catdir('pdt20_mini', 'data')
Expand Down

0 comments on commit a9a854b

Please sign in to comment.