Commit 0a4543de0f65f6a207dc3405f28dcaf722462a6f

Authored by AntonioTerceiro
1 parent b443571b

ActionItem23: limiting the number of articles



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1122 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/rss_feed.rb
... ... @@ -23,7 +23,7 @@ class RssFeed < Article
23 23 if (self.settings[:include] == :parent_and_children) && self.parent
24 24 self.parent.map_traversal
25 25 else
26   - profile.recent_documents(10)
  26 + profile.recent_documents(self.settings[:limit] || 10)
27 27 end
28 28  
29 29  
... ...
test/unit/rss_feed_test.rb
... ... @@ -107,7 +107,21 @@ class RssFeedTest < Test::Unit::TestCase
107 107 end
108 108  
109 109 should 'be able to indicate maximum number of items' do
110   - flunk 'pending'
  110 + profile = create_user('testuser').person
  111 + a1 = profile.articles.build(:name => 'article 1'); a1.save!
  112 + a2 = profile.articles.build(:name => 'article 2'); a2.save!
  113 + a3 = profile.articles.build(:name => 'article 3'); a3.save!
  114 +
  115 + feed = RssFeed.new(:name => 'feed')
  116 + feed.profile = profile
  117 + feed.save!
  118 +
  119 + feed.profile.expects(:recent_documents).with(10).returns([]).once
  120 + feed.data
  121 +
  122 + feed.settings[:limit] = 5
  123 + feed.profile.expects(:recent_documents).with(5).returns([]).once
  124 + feed.data
111 125 end
112 126  
113 127 end
... ...