Commit 90f24f9a69d987de1a907430c2e9eff93b309653

Authored by AntonioTerceiro
1 parent 285463b5

ActionItem573: listing most recent first

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2294 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/category_finder.rb
... ... @@ -27,7 +27,7 @@ class CategoryFinder
27 27 end
28 28  
29 29 def recent(asset, limit = nil)
30   - find(asset, nil, :limit => limit)
  30 + find(asset, nil, :limit => limit, :order => 'created_at DESC, id DESC')
31 31 end
32 32  
33 33 def most_commented_articles(limit=10, options={})
... ...
test/unit/category_finder_test.rb
... ... @@ -163,13 +163,12 @@ class CategoryFinderTest < ActiveSupport::TestCase
163 163  
164 164 should 'list recent articles' do
165 165 person = create_user('teste').person
166   - art1 = person.articles.build(:name => 'an article to be found'); art1.add_category(@category); art1.save!
167   -
168   - art2 = person.articles.build(:name => 'another article to be found'); art2.add_category(@category); art2.save!
  166 + art1 = person.articles.create!(:name => 'an article to be found', :category_ids => [@category.id])
  167 + art2 = person.articles.create!(:name => 'another article to be found', :category_ids => [@category.id])
169 168  
170 169 result = @finder.recent('articles', 1)
171 170  
172   - assert_equal 1, result.size
  171 + assert_equal [art2], result
173 172 end
174 173  
175 174 should 'not return the same result twice' do
... ...