Commit e7cfa55e293281292f89fa201d5200f8a37f4846

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent 54d83dd0

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)
app/models/rss_feed.rb
@@ -75,7 +75,6 @@ class RssFeed < Article @@ -75,7 +75,6 @@ class RssFeed < Article
75 end 75 end
76 def data 76 def data
77 articles = fetch_articles 77 articles = fetch_articles
78 -  
79 result = "" 78 result = ""
80 xml = Builder::XmlMarkup.new(:target => result) 79 xml = Builder::XmlMarkup.new(:target => result)
81 80
@@ -91,7 +90,7 @@ class RssFeed < Article @@ -91,7 +90,7 @@ class RssFeed < Article
91 xml.item do 90 xml.item do
92 xml.title(article.name) 91 xml.title(article.name)
93 if self.feed_item_description == 'body' 92 if self.feed_item_description == 'body'
94 - xml.description(article.body) 93 + xml.description(article.to_html)
95 else 94 else
96 xml.description(article.abstract) 95 xml.description(article.abstract)
97 end 96 end
test/factories.rb
@@ -248,6 +248,10 @@ module Noosfero::Factory @@ -248,6 +248,10 @@ module Noosfero::Factory
248 ############################################### 248 ###############################################
249 # Blog 249 # Blog
250 ############################################### 250 ###############################################
  251 + def defaults_for_blog
  252 + { :name => 'My blog ' + factory_num_seq.to_s }
  253 + end
  254 +
251 def create_blog 255 def create_blog
252 profile = Profile.create!(:identifier => 'testuser' + factory_num_seq.to_s, :name => 'Test user') 256 profile = Profile.create!(:identifier => 'testuser' + factory_num_seq.to_s, :name => 'Test user')
253 Blog.create!(:name => 'blog', :profile => profile) 257 Blog.create!(:name => 'blog', :profile => profile)
test/unit/rss_feed_test.rb
@@ -240,4 +240,15 @@ class RssFeedTest < Test::Unit::TestCase @@ -240,4 +240,15 @@ class RssFeedTest < Test::Unit::TestCase
240 assert_equal false, a.can_display_hits? 240 assert_equal false, a.can_display_hits?
241 end 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 end 254 end