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 << "
"
- results_by_year.group_by{|i| [ ('%02d' % i.published_at.month()), gettext(MONTHS[i.published_at.month() - 1])]}.sort.each do |month, results_by_month|
+ results_by_year.group_by{|i| [ ('%02d' % i.published_at.month()), gettext(MONTHS[i.published_at.month() - 1])]}.sort.reverse.each do |month, results_by_month|
results << content_tag('li', link_to("#{month[1]} (#{results_by_month.size})", owner.generate_url(:controller => 'content_viewer', :action => 'view_page', :page => [owner.blog.path], :year => year, :month => month[0])))
end
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