8 |
|
|
9 |
=cut |
=cut |
10 |
|
|
11 |
use Jifty::Test tests => 15; |
use Jifty::Test tests => 29; |
12 |
|
|
13 |
# Make sure we can load the action |
# Make sure we can load the action |
14 |
use_ok('Grep::Action::Search'); |
use_ok('Grep::Action::Search'); |
21 |
my $system_user = Grep::CurrentUser->superuser; |
my $system_user = Grep::CurrentUser->superuser; |
22 |
ok($system_user, "Found a system user"); |
ok($system_user, "Found a system user"); |
23 |
|
|
24 |
|
{ |
25 |
|
use Log::Log4perl::Level; |
26 |
|
Jifty->web->log->level( $DEBUG ); |
27 |
|
} |
28 |
|
|
29 |
# create test feed |
# create test feed |
30 |
my $feed = Grep::Model::Feed->new(current_user => $system_user); |
my $feed = Grep::Model::Feed->new(current_user => $system_user); |
31 |
my ($id) = $feed->create( |
my ($id) = $feed->create( |
48 |
ok($o->id, "New Item has valid id set"); |
ok($o->id, "New Item has valid id set"); |
49 |
is($o->id, $id, "Create returned the right id"); |
is($o->id, $id, "Create returned the right id"); |
50 |
|
|
51 |
|
use_ok('Grep::Search'); |
52 |
|
ok(my $index = Grep::Search->new, 'Grep::Search->new'); |
53 |
|
isa_ok( $index, 'Grep::Search' ); |
54 |
|
|
55 |
|
ok($index->add( $o, $system_user->id ), 'add ' . $o->id ); |
56 |
|
|
57 |
|
ok($index->finish, 'finish'); |
58 |
|
|
59 |
# Searches in general |
# Searches in general |
60 |
my $collection = Grep::Model::ItemCollection->new(current_user => $system_user); |
my $collection = Grep::Model::ItemCollection->new(current_user => $system_user); |
61 |
$collection->unlimit; |
$collection->unlimit; |
70 |
|
|
71 |
isa_ok($search, 'Grep::Action::Search'); |
isa_ok($search, 'Grep::Action::Search'); |
72 |
|
|
|
{ |
|
|
use Log::Log4perl::Level; |
|
|
Jifty->web->log->level( $DEBUG ); |
|
|
} |
|
|
|
|
73 |
my %args = %{$search->arguments}; |
my %args = %{$search->arguments}; |
74 |
|
|
75 |
ok($args{q}, "Can search on q"); |
ok($args{q}, "Can search on q"); |
82 |
|
|
83 |
isa_ok($result, 'Jifty::Collection'); |
isa_ok($result, 'Jifty::Collection'); |
84 |
is($result->count, 1); |
is($result->count, 1); |
|
is($result->first->name, 'test1'); |
|
85 |
|
|
86 |
|
isa_ok( $result->first, 'Grep::Model::Item' ); |
87 |
|
|
88 |
|
eval { |
89 |
|
is($result->first->in_feed->id, $feed->id); |
90 |
|
is($result->first->title, 'example title'); |
91 |
|
is($result->first->link, 'http://www.example.com/item1'); |
92 |
|
is($result->first->content, 'some content'); |
93 |
|
}; |
94 |
|
|
95 |
|
ok($index = Grep::Search->new, 'Grep::Search->new'); |
96 |
|
isa_ok( $index, 'Grep::Search' ); |
97 |
|
ok($index->invindexer->delete_by_term( 'id', $o->id ), 'invindexer->delete_by_term( id, ' . $o->id . ')' ); |
98 |
|
|
99 |
|
ok($index->finish, 'finish'); |