Commit 11619aa74dc09890d5d49b65cf0c1bd9b7cfb617
1 parent
3d567c77
Exists in
master
and in
29 other branches
Apply proper ordering in the per-tag RSS feeds
(ActionItem1552)
Showing
2 changed files
with
22 additions
and
1 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -31,7 +31,7 @@ class ProfileController < PublicController |
31 | 31 | |
32 | 32 | def tag_feed |
33 | 33 | @tag = params[:id] |
34 | - tagged = profile.find_tagged_with(@tag).paginate(:per_page => 20, :page => 1) | |
34 | + tagged = profile.articles.paginate(:per_page => 20, :page => 1, :order => 'published_at DESC', :include => :tags, :conditions => ['tags.name LIKE ?', @tag]) | |
35 | 35 | feed_writer = FeedWriter.new |
36 | 36 | data = feed_writer.write( |
37 | 37 | tagged, | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -704,4 +704,25 @@ class ProfileControllerTest < Test::Unit::TestCase |
704 | 704 | assert_response 302 |
705 | 705 | end |
706 | 706 | |
707 | + should 'reverse the order of posts in tag feed' do | |
708 | + TextileArticle.create!(:name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) | |
709 | + TextileArticle.create!(:name => 'Second post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now + 1.day) | |
710 | + | |
711 | + get :tag_feed, :profile => profile.identifier, :id => 'tag1' | |
712 | + assert_match(/Second.*First/, @response.body) | |
713 | + end | |
714 | + | |
715 | + should 'display the most recent posts in tag feed' do | |
716 | + start = Time.now - 30.days | |
717 | + first = TextileArticle.create!(:name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => start) | |
718 | + 20.times do |i| | |
719 | + TextileArticle.create!(:name => 'Post #' + i.to_s, :profile => profile, :tag_list => 'tag1', :published_at => start + i.days) | |
720 | + end | |
721 | + last = TextileArticle.create!(:name => 'Last post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) | |
722 | + | |
723 | + get :tag_feed, :profile => profile.identifier, :id => 'tag1' | |
724 | + assert_no_match(/First post/, @response.body) # First post is older than other 20 posts already | |
725 | + assert_match(/Last post/, @response.body) # Latest post must come in the feed | |
726 | + end | |
727 | + | |
707 | 728 | end | ... | ... |