Add a method to return RSS data for a Story, with tests.
This commit is contained in:
parent
721acb69eb
commit
3853e4dd02
2 changed files with 46 additions and 3 deletions
|
|
@ -454,6 +454,27 @@ sub getPhotoData {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getRssData ( )
|
||||||
|
|
||||||
|
Returns RSS data for this Story. The date of the RSS item is the lastModified
|
||||||
|
property of the Asset.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getRssData {
|
||||||
|
my $self = shift;
|
||||||
|
my $data = {
|
||||||
|
title => $self->get('headline') || $self->getTitle,
|
||||||
|
description => $self->get('subtitle'),
|
||||||
|
'link' => $self->getUrl,
|
||||||
|
author => $self->get('byline'),
|
||||||
|
date => $self->get('lastModified'),
|
||||||
|
};
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 prepareView ( $templateId )
|
=head2 prepareView ( $templateId )
|
||||||
|
|
||||||
See WebGUI::Asset::prepareView() for details.
|
See WebGUI::Asset::prepareView() for details.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ use Test::More; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $tests = 1;
|
my $tests = 34;
|
||||||
plan tests => 32
|
plan tests => 1
|
||||||
+ $tests
|
+ $tests
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -80,6 +80,8 @@ ok( WebGUI::Asset::Story->validParent($session), 'validParent: StoryArchive is
|
||||||
$story = $archive->addChild({
|
$story = $archive->addChild({
|
||||||
className => 'WebGUI::Asset::Story',
|
className => 'WebGUI::Asset::Story',
|
||||||
title => 'Story 1',
|
title => 'Story 1',
|
||||||
|
subtitle => 'The story of a CMS',
|
||||||
|
byline => 'JT Smith',
|
||||||
});
|
});
|
||||||
|
|
||||||
isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset');
|
isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset');
|
||||||
|
|
@ -198,11 +200,31 @@ cmp_deeply(
|
||||||
url => $story->getUrl,
|
url => $story->getUrl,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'getCrumbTrail: with no topic set'
|
'getCrumbTrail: with topic set'
|
||||||
);
|
);
|
||||||
|
|
||||||
$story->topic('');
|
$story->topic('');
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# getRssData
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
can_ok($story, 'getRssData');
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$story->getRssData,
|
||||||
|
{
|
||||||
|
title => 'Story 1',
|
||||||
|
description => 'The story of a CMS',
|
||||||
|
'link' => re('story-1$'),
|
||||||
|
author => 'JT Smith',
|
||||||
|
date => $story->get('lastModified'),
|
||||||
|
},
|
||||||
|
'getRssData: returns correct data'
|
||||||
|
);
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
#
|
#
|
||||||
# viewTemplateVariables
|
# viewTemplateVariables
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue