Commit e7cfa55e293281292f89fa201d5200f8a37f4846
Committed by
Antonio Terceiro
1 parent
54d83dd0
Exists in
master
and in
28 other branches
PublishedArticle's body is displayed in the feed
* The problem ocurred because the body of PublishedArticles is empty and it must call the body of the article to which it references to. This is done through the to_html method. * Also included fast_create defaults for blog. (ActionItem1395)
Showing
3 changed files
with
16 additions
and
2 deletions
Show diff stats
app/models/rss_feed.rb
| ... | ... | @@ -75,7 +75,6 @@ class RssFeed < Article |
| 75 | 75 | end |
| 76 | 76 | def data |
| 77 | 77 | articles = fetch_articles |
| 78 | - | |
| 79 | 78 | result = "" |
| 80 | 79 | xml = Builder::XmlMarkup.new(:target => result) |
| 81 | 80 | |
| ... | ... | @@ -91,7 +90,7 @@ class RssFeed < Article |
| 91 | 90 | xml.item do |
| 92 | 91 | xml.title(article.name) |
| 93 | 92 | if self.feed_item_description == 'body' |
| 94 | - xml.description(article.body) | |
| 93 | + xml.description(article.to_html) | |
| 95 | 94 | else |
| 96 | 95 | xml.description(article.abstract) |
| 97 | 96 | end | ... | ... |
test/factories.rb
| ... | ... | @@ -248,6 +248,10 @@ module Noosfero::Factory |
| 248 | 248 | ############################################### |
| 249 | 249 | # Blog |
| 250 | 250 | ############################################### |
| 251 | + def defaults_for_blog | |
| 252 | + { :name => 'My blog ' + factory_num_seq.to_s } | |
| 253 | + end | |
| 254 | + | |
| 251 | 255 | def create_blog |
| 252 | 256 | profile = Profile.create!(:identifier => 'testuser' + factory_num_seq.to_s, :name => 'Test user') |
| 253 | 257 | Blog.create!(:name => 'blog', :profile => profile) | ... | ... |
test/unit/rss_feed_test.rb
| ... | ... | @@ -240,4 +240,15 @@ class RssFeedTest < Test::Unit::TestCase |
| 240 | 240 | assert_equal false, a.can_display_hits? |
| 241 | 241 | end |
| 242 | 242 | |
| 243 | + should 'display the referenced body of a PublishedArticle' do | |
| 244 | + article = fast_create(Article, :body => 'This is the content of the Sample Article.') | |
| 245 | + profile = fast_create(Profile) | |
| 246 | + blog = fast_create(Blog, :profile_id => profile.id) | |
| 247 | + published_article = PublishedArticle.create!(:reference_article => article, :profile => profile) | |
| 248 | + blog.posts << published_article | |
| 249 | + feed = RssFeed.new(:parent => blog, :profile => profile, :feed_item_description => 'body') | |
| 250 | + | |
| 251 | + assert_match published_article.to_html, feed.data | |
| 252 | + end | |
| 253 | + | |
| 243 | 254 | end | ... | ... |