From e283f47133d51ac066571543f000f7d53f4b62dd Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Wed, 17 Jun 2009 17:33:30 -0300 Subject: [PATCH] ActionItem1141: reverse the ordering of posts --- app/models/blog_archives_block.rb | 2 +- test/unit/blog_archives_block_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/blog_archives_block.rb b/app/models/blog_archives_block.rb index d2c95b5..e9093ab 100644 --- a/app/models/blog_archives_block.rb +++ b/app/models/blog_archives_block.rb @@ -21,7 +21,7 @@ class BlogArchivesBlock < Block posts.group_by {|i| i.published_at.year }.sort_by { |year,count| -year }.each do |year, results_by_year| results << content_tag('li', content_tag('strong', "#{year} (#{results_by_year.size})")) results << "" diff --git a/test/unit/blog_archives_block_test.rb b/test/unit/blog_archives_block_test.rb index b4441ed..c7121a5 100644 --- a/test/unit/blog_archives_block_test.rb +++ b/test/unit/blog_archives_block_test.rb @@ -66,6 +66,16 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase assert_match(/2009.*2008.*2007.*2006.*2005/m, block.content) end + should 'order months from later to former' do + blog = profile.blog + for month in 1..3 + post = TextileArticle.create!(:name => "post #{month}", :profile => profile, :parent => blog, :published_at => Date.new(2009, month, 1)) + end + block = BlogArchivesBlock.new + block.stubs(:owner).returns(profile) + assert_match(/.*March.*February.*January.*/m, block.content) + end + should 'not display any content if has no blog' do profile.stubs(:has_blog?).returns(false) assert !profile.has_blog? -- libgit2 0.21.2