From ee75426963dac13426928c780038606b63e92b69 Mon Sep 17 00:00:00 2001
From: Raphael Sofaer <raphael@joindiaspora.com>
Date: Wed, 1 Jun 2011 13:24:18 -0700
Subject: [PATCH] Add failing spec for being overloaded with updated pending
 photos

---
 spec/factories.rb                 | 4 ----
 spec/models/user/querying_spec.rb | 8 ++++++++
 spec/spec_helper.rb               | 4 ++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/spec/factories.rb b/spec/factories.rb
index 63216ab6c0..db83249dcd 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -75,10 +75,6 @@ Factory.define(:status_message) do |m|
   end
 end
 
-Factory.define :photo do |p|
-  p.image File.open( File.dirname(__FILE__) + '/fixtures/button.png')
-end
-
 Factory.define :service do |service|
   service.nickname "sirrobertking"
   service.type "Services::Twitter"
diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb
index 9e1a6db644..e5dcf7079f 100644
--- a/spec/models/user/querying_spec.rb
+++ b/spec/models/user/querying_spec.rb
@@ -118,6 +118,14 @@ describe User do
         eve.find_visible_post_by_id(@status_message1.id).should == @status_message1
         eve.find_visible_post_by_id(@status_message5.id).should == nil
       end
+
+      it 'is not emptied by a load of pending photos' do
+        15.times {
+          eve.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name), :to => eve.aspect_ids, :updated_at => Time.now + 1.day).save!
+        }
+        query = eve.visible_posts
+        query.map{|p| p.id}.should =~ [@status_message1, @status_message2, @status_message3, @status_message4].map{|p| p.id}
+      end
     end
   end
 
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index ee0c8ff4af..eeb3736430 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -79,3 +79,7 @@ end
 def remote_raphael
   @remote_raphael ||= Person.where(:diaspora_handle => 'raphael@remote.net').first
 end
+
+def photo_fixture_name
+    @photo_fixture_name = File.join(File.dirname(__FILE__), 'fixtures', 'button.png')
+end
-- 
GitLab