From 90f24f9a69d987de1a907430c2e9eff93b309653 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Mon, 21 Jul 2008 18:24:16 +0000 Subject: [PATCH] ActionItem573: listing most recent first --- app/models/category_finder.rb | 2 +- test/unit/category_finder_test.rb | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/category_finder.rb b/app/models/category_finder.rb index 2e36d8d..539b61c 100644 --- a/app/models/category_finder.rb +++ b/app/models/category_finder.rb @@ -27,7 +27,7 @@ class CategoryFinder end def recent(asset, limit = nil) - find(asset, nil, :limit => limit) + find(asset, nil, :limit => limit, :order => 'created_at DESC, id DESC') end def most_commented_articles(limit=10, options={}) diff --git a/test/unit/category_finder_test.rb b/test/unit/category_finder_test.rb index 8f08f3a..2e0861f 100644 --- a/test/unit/category_finder_test.rb +++ b/test/unit/category_finder_test.rb @@ -163,13 +163,12 @@ class CategoryFinderTest < ActiveSupport::TestCase should 'list recent articles' do person = create_user('teste').person - art1 = person.articles.build(:name => 'an article to be found'); art1.add_category(@category); art1.save! - - art2 = person.articles.build(:name => 'another article to be found'); art2.add_category(@category); art2.save! + art1 = person.articles.create!(:name => 'an article to be found', :category_ids => [@category.id]) + art2 = person.articles.create!(:name => 'another article to be found', :category_ids => [@category.id]) result = @finder.recent('articles', 1) - assert_equal 1, result.size + assert_equal [art2], result end should 'not return the same result twice' do -- libgit2 0.21.2