getRssFeedItems for StoryArchive, with tests.
A couple of quick rss/atom url tests.
This commit is contained in:
parent
3853e4dd02
commit
efef611b03
2 changed files with 68 additions and 5 deletions
|
|
@ -210,6 +210,30 @@ sub getFolder {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getRssFeedItems ( )
|
||||
|
||||
Returns an arrayref of hashrefs, containing information on stories
|
||||
for generating an RSS and Atom feeds.
|
||||
|
||||
=cut
|
||||
|
||||
sub getRssFeedItems {
|
||||
my $self = shift;
|
||||
my $stories = $self->getLineageIterator(['descendants'],{
|
||||
excludeClasses => ['WebGUI::Asset::Wobject::Folder'],
|
||||
orderByClause => 'creationDate desc, lineage',
|
||||
returnObjects => 1,
|
||||
limit => $self->get('itemsPerFeed'),
|
||||
});
|
||||
my $storyData = [];
|
||||
while (my $story = $stories->()) {
|
||||
push @{ $storyData }, $story->getRssData;
|
||||
}
|
||||
return $storyData;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 folderDateFormat ( $epoch )
|
||||
|
||||
Returns the date in the format for folders. Encapsulated in this method
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ $canPostMaker->prepare({
|
|||
fail => [1, $reader ],
|
||||
});
|
||||
|
||||
my $tests = 1;
|
||||
plan tests => 28
|
||||
+ $tests
|
||||
+ $canPostMaker->plan
|
||||
;
|
||||
my $tests = 31
|
||||
+ $canPostMaker->plan
|
||||
;
|
||||
plan tests => 1
|
||||
+ $tests;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -387,6 +387,45 @@ cmp_bag(
|
|||
'keywordCloud template variable has keywords and correct links',
|
||||
);
|
||||
|
||||
################################################################
|
||||
#
|
||||
# RSS and Atom checks
|
||||
#
|
||||
################################################################
|
||||
|
||||
is($archive->getRssFeedUrl, '/home/mystories?func=viewRss', 'RSS Feed Url');
|
||||
is($archive->getAtomFeedUrl, '/home/mystories?func=viewAtom', 'Atom Feed Url');
|
||||
|
||||
$archive->update({itemsPerFeed => 3});
|
||||
|
||||
cmp_deeply(
|
||||
$archive->getRssFeedItems(),
|
||||
[
|
||||
{
|
||||
title => 'First Story',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
{
|
||||
title => 'Story 2',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
{
|
||||
title => 'Story 3',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
],
|
||||
'rssFeedItems'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue