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