Commit 90f24f9a69d987de1a907430c2e9eff93b309653
1 parent
285463b5
Exists in
master
and in
22 other branches
ActionItem573: listing most recent first
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2294 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
4 additions
and
5 deletions
Show diff stats
app/models/category_finder.rb
| @@ -27,7 +27,7 @@ class CategoryFinder | @@ -27,7 +27,7 @@ class CategoryFinder | ||
| 27 | end | 27 | end |
| 28 | 28 | ||
| 29 | def recent(asset, limit = nil) | 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 | end | 31 | end |
| 32 | 32 | ||
| 33 | def most_commented_articles(limit=10, options={}) | 33 | def most_commented_articles(limit=10, options={}) |
test/unit/category_finder_test.rb
| @@ -163,13 +163,12 @@ class CategoryFinderTest < ActiveSupport::TestCase | @@ -163,13 +163,12 @@ class CategoryFinderTest < ActiveSupport::TestCase | ||
| 163 | 163 | ||
| 164 | should 'list recent articles' do | 164 | should 'list recent articles' do |
| 165 | person = create_user('teste').person | 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 | result = @finder.recent('articles', 1) | 169 | result = @finder.recent('articles', 1) |
| 171 | 170 | ||
| 172 | - assert_equal 1, result.size | 171 | + assert_equal [art2], result |
| 173 | end | 172 | end |
| 174 | 173 | ||
| 175 | should 'not return the same result twice' do | 174 | should 'not return the same result twice' do |