8 |
|
|
9 |
=cut |
=cut |
10 |
|
|
11 |
use Jifty::Test tests => 1; |
use Jifty::Test tests => 10; |
12 |
|
|
13 |
# Make sure we can load the action |
# Make sure we can load the action |
14 |
use_ok('Grep::Action::Fetch'); |
use_ok('Grep::Action::Fetch'); |
15 |
|
|
16 |
|
# Grab a system user |
17 |
|
my $system_user = Grep::CurrentUser->superuser; |
18 |
|
ok($system_user, "Found a system user"); |
19 |
|
|
20 |
|
{ |
21 |
|
use Log::Log4perl::Level; |
22 |
|
Jifty->web->log->level( $DEBUG ); |
23 |
|
} |
24 |
|
|
25 |
|
my $feed = Grep::Model::Feed->new(current_user => $system_user); |
26 |
|
my ($feed_id) = $feed->create( |
27 |
|
uri => 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13?search_term=%s', |
28 |
|
title => 'rot13.org wiki', |
29 |
|
); |
30 |
|
ok( $feed_id, 'feed->create' ); |
31 |
|
|
32 |
|
my $fetch = Jifty::Test->web->new_action( |
33 |
|
class => 'Fetch', |
34 |
|
moniker => 'fetch', |
35 |
|
current_user => $system_user, |
36 |
|
arguments => {} |
37 |
|
); |
38 |
|
|
39 |
|
isa_ok($fetch, 'Grep::Action::Fetch'); |
40 |
|
|
41 |
|
my %args = %{$fetch->arguments}; |
42 |
|
|
43 |
|
ok($args{q}, "Can fetch on q"); |
44 |
|
|
45 |
|
# fetch on q |
46 |
|
$fetch->argument_values({ q => 'Grep test page', feed => $feed_id }); |
47 |
|
$fetch->run; |
48 |
|
|
49 |
|
my $result = $fetch->result->content('items'); |
50 |
|
|
51 |
|
isa_ok($result, 'Jifty::Collection'); |
52 |
|
cmp_ok($result->count, '>=', 1, 'count'); |
53 |
|
|
54 |
|
diag "found ", $result->count, " results"; |
55 |
|
|
56 |
|
isa_ok( $result->first, 'Grep::Model::Item' ); |
57 |
|
|
58 |
|
is($result->first->in_feed->id, $feed_id, 'feed id'); |
59 |
|
like($result->first->link, qr#http://saturn.ffzg.hr/rot13#, 'link'); |
60 |
|
|
61 |
|
$feed->delete; |
62 |
|
|