Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The deterministic-stream-order Reloaded - participations

  • Loading branch information...
commit 910911fc4a55972651d3ae3b4588778bd99bc3cd 1 parent 9e50d0e
Florian Staudacher Raven24 authored
Showing with 23 additions and 2 deletions.
  1. +1 −1  lib/evil_query.rb
  2. +22 −1 spec/lib/evil_query_spec.rb
2  lib/evil_query.rb
View
@@ -17,7 +17,7 @@ def initialize(user)
end
def posts
- Post.joins(:participations).where(:participations => {:author_id => @user.person.id}).order("posts.interacted_at DESC")
+ Post.joins(:participations).where(:participations => {:author_id => @user.person.id}).order("posts.interacted_at DESC").order("participations.id DESC")
end
end
23 spec/lib/evil_query_spec.rb
View
@@ -58,4 +58,25 @@
posts.map(&:id).should == [@status_messageE.id, @photoC.id, @status_messageA.id, @status_messageB.id]
end
end
-end
+
+ describe "posts with the same timestamp" do
+ before do
+ @status_msgZ = Factory(:status_message, :author => bob.person)
+ @status_msgY = Factory(:status_message, :author => bob.person)
+ @status_msgX = Factory(:activity_streams_photo, :author => bob.person)
+
+ Timecop.freeze do
+ alice.like!(@status_msgY)
+ alice.comment!(@status_msgZ, "party")
+ alice.like!(@status_msgX)
+ end
+ end
+
+ let(:posts) {EvilQuery::Participation.new(alice).posts}
+
+ it "returns the posts in the reverse order they were interacted with" do
+ posts.map(&:id).should == [@status_msgX.id, @status_msgZ.id, @status_msgY.id]
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.