From efe79eb3517e4e77c979aa19492457326686bbb3 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 13 Apr 2011 14:35:20 -0700 Subject: [PATCH] Fix stream on pages other than 1, rename raw_visible_posts to visible_posts --- app/controllers/apis_controller.rb | 14 +++--- app/controllers/aspects_controller.rb | 8 +++- app/helpers/aspects_helper.rb | 3 ++ app/models/post.rb | 2 +- app/views/aspects/_aspect_stream.haml | 2 +- app/views/aspects/index.mobile.haml | 7 +-- app/views/shared/_stream_element.html.haml | 2 +- lib/collect_user_photos.rb | 2 +- lib/diaspora/exporter.rb | 2 +- lib/diaspora/user/querying.rb | 17 +++---- lib/fake.rb | 2 +- public/javascripts/infinite-scroll.js | 5 +- .../javascripts/widgets/directionDetector.js | 6 +-- spec/integration/receiving_spec.rb | 12 ++--- spec/misc_spec.rb | 2 +- spec/models/user/attack_vectors_spec.rb | 16 +++---- spec/models/user/connecting_spec.rb | 4 +- spec/models/user/posting_spec.rb | 4 +- spec/models/user/querying_spec.rb | 47 +++++++++++-------- 19 files changed, 88 insertions(+), 69 deletions(-) diff --git a/app/controllers/apis_controller.rb b/app/controllers/apis_controller.rb index 1a24696c5..af8fe2c24 100644 --- a/app/controllers/apis_controller.rb +++ b/app/controllers/apis_controller.rb @@ -1,7 +1,7 @@ class ApisController < ApplicationController #We should start with this versioned, V0ApisController BEES before_filter :authenticate_user!, :only => [:home_timeline] respond_to :json - + #posts def public_timeline set_defaults @@ -30,9 +30,9 @@ class ApisController < ApplicationController #We should start with this versione def home_timeline set_defaults - timeline = current_user.raw_visible_posts.includes(:comments, :photos, :likes, :dislikes).paginate( - :page => params[:page], :per_page => params[:per_page], :order => "#{params[:order]} DESC") - + timeline = current_user.visible_posts(:max_time => params[:max_time], + :per_page => params[:per_page], + :order => "#{params[:order]} DESC").includes(:comments, :photos, :likes, :dislikes) respond_with timeline do |format| format.json{ render :json => timeline.to_json(:format => :twitter) } end @@ -45,7 +45,7 @@ class ApisController < ApplicationController #We should start with this versione format.json{ render :json => status.to_json(:format => :twitter) } end else - render(:nothing => true, :status => 404) + render(:nothing => true, :status => 404) end end @@ -62,7 +62,7 @@ class ApisController < ApplicationController #We should start with this versione format.json{ render :json => person.to_json(:format => :twitter) } end else - render(:nothing => true, :status => 404) + render(:nothing => true, :status => 404) end end @@ -78,7 +78,7 @@ class ApisController < ApplicationController #We should start with this versione format.json{ render :json => people.to_json(:format => :twitter) } end else - render(:nothing => true, :status => 404) + render(:nothing => true, :status => 404) end end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 9a66779aa..6da08ba72 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -30,10 +30,10 @@ class AspectsController < ApplicationController @selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq unless params[:only_posts] @aspect_ids = @aspects.map { |a| a.id } - posts = current_user.raw_visible_posts(:by_members_of => @aspect_ids, + posts = current_user.visible_posts(:by_members_of => @aspect_ids, :type => 'StatusMessage', :order => session[:sort_order] + ' DESC', - :page => params[:page] + :max_time => params[:max_time].to_i ).includes(:comments, :mentions, :likes, :dislikes) @posts = PostsFake.new(posts) @@ -160,6 +160,10 @@ class AspectsController < ApplicationController @aspect.save end + def ensure_page + params[:max_time] ||= Time.now + 1 + end + protected def save_sort_order diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index 147704c3f..8461d633d 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -3,6 +3,9 @@ # the COPYRIGHT file. module AspectsHelper + def next_page_path + aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids]) + end def link_for_aspect(aspect, opts={}) opts[:params] ||= {} params ||= {} diff --git a/app/models/post.rb b/app/models/post.rb index 333dc1313..77f5c34cb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -77,7 +77,7 @@ class Post < ActiveRecord::Base local_post = Post.where(:guid => self.guid).first if local_post && local_post.author_id == self.author_id - known_post = user.raw_visible_posts.where(:guid => self.guid).first + known_post = user.visible_posts.where(:guid => self.guid).first if known_post if known_post.mutable? known_post.update_attributes(self.attributes) diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index 78f540716..d49a64342 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -13,6 +13,6 @@ - if posts.length > 0 = render 'shared/stream', :posts => posts #pagination - =link_to(t('more'), aspects_path(:page => next_page, :a_ids => params[:a_ids]), :class => 'paginate') + =link_to(t('more'), next_page_path, :class => 'paginate') - else = render 'aspects/no_posts_message', :post_count => posts.length diff --git a/app/views/aspects/index.mobile.haml b/app/views/aspects/index.mobile.haml index a6e78e163..8def29594 100644 --- a/app/views/aspects/index.mobile.haml +++ b/app/views/aspects/index.mobile.haml @@ -12,8 +12,9 @@ = link_to t('.post_a_message'), '#publisher_page', :id => 'publisher_button' #main_stream.stream = render 'shared/stream', :posts => @posts - #pagination - %a.more-link.paginate{:href => aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1)} - %h2= t("more") + -if @posts.length > 0 + #pagination + %a.more-link.paginate{:href => next_page_path} + %h2= t("more") - content_for :subpages do = render 'shared/publisher', :aspect_ids => @aspect_ids diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 614e66472..b2ef0b58c 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -21,7 +21,7 @@ .content .from = person_link(post.author, :class => 'author') - %time.timeago{:datetime => post.created_at} + %time.timeago{:datetime => post.created_at, :integer => post.created_at.to_i} = render 'status_messages/status_message', :post => post, :photos => post.photos .info diff --git a/lib/collect_user_photos.rb b/lib/collect_user_photos.rb index 358ce4e0c..f91875a0b 100644 --- a/lib/collect_user_photos.rb +++ b/lib/collect_user_photos.rb @@ -5,7 +5,7 @@ module PhotoMover FileUtils::mkdir_p temp_dir Dir.chdir 'tmp/exports' - photos = user.raw_visible_posts.where(:author_id => user.person.id, :type => 'Photo') + photos = user.visible_posts.where(:author_id => user.person.id, :type => 'Photo') photos_dir = "#{user.id}/photos" FileUtils::mkdir_p photos_dir diff --git a/lib/diaspora/exporter.rb b/lib/diaspora/exporter.rb index adb33d26d..36e71444b 100644 --- a/lib/diaspora/exporter.rb +++ b/lib/diaspora/exporter.rb @@ -64,7 +64,7 @@ module Diaspora } xml.posts { - user.raw_visible_posts.find_all_by_author_id(user_person_id).each do |post| + user.visible_posts.find_all_by_author_id(user_person_id).each do |post| #post.comments.each do |comment| # post_doc << comment.to_xml #end diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 6d745f41a..377a4d193 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -12,15 +12,16 @@ module Diaspora post ||= Post.where(:id => id, :public => true).where(opts).first end - def raw_visible_posts(opts = {}) + def visible_posts(opts = {}) opts = opts.dup opts[:type] ||= ['StatusMessage', 'Photo'] opts[:limit] ||= 15 opts[:order] ||= 'updated_at DESC' + order_field = opts[:order].split.first.to_sym opts[:hidden] ||= false order_with_table = 'posts.' + opts[:order] - opts[:page] ||= 1 - opts[:offset] = opts[:page] == 1 ? 0 : opts[:limit] * (opts[:page] - 1) + opts[:max_time] = Time.at(opts[:max_time]) if opts[:max_time].instance_of?(Fixnum) + opts[:max_time] ||= Time.now + 1 select_clause ='DISTINCT posts.id, posts.updated_at AS updated_at, posts.created_at AS created_at' posts_from_others = Post.joins(:contacts).where( :post_visibilities => {:hidden => opts[:hidden]}, :contacts => {:user_id => self.id}) @@ -32,17 +33,17 @@ module Diaspora posts_from_self = posts_from_self.joins(:aspect_visibilities).where(:aspect_visibilities => {:aspect_id => opts[:by_members_of]}) end - posts_from_others = posts_from_others.select(select_clause).limit(opts[:limit]*opts[:page]).order(order_with_table) - posts_from_self = posts_from_self.select(select_clause).limit(opts[:limit]*opts[:page]).order(order_with_table) + posts_from_others = posts_from_others.select(select_clause).limit(opts[:limit]).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time])) + posts_from_self = posts_from_self.select(select_clause).limit(opts[:limit]).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time])) - all_posts = "(#{posts_from_others.to_sql}) UNION ALL (#{posts_from_self.to_sql}) ORDER BY #{opts[:order]} LIMIT #{opts[:limit]} OFFSET #{opts[:offset]}" + all_posts = "(#{posts_from_others.to_sql}) UNION ALL (#{posts_from_self.to_sql}) ORDER BY #{opts[:order]} LIMIT #{opts[:limit]}" post_ids = Post.connection.execute(all_posts).map{|r| r.first} Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT posts.*').limit(opts[:limit]).order(order_with_table) end - def visible_photos - raw_visible_posts(:type => 'Photo') + def visible_photos(opts = {}) + visible_posts(opts.merge(:type => 'Photo')) end def contact_for(person) diff --git a/lib/fake.rb b/lib/fake.rb index 77050ff10..2a1c86d27 100644 --- a/lib/fake.rb +++ b/lib/fake.rb @@ -1,6 +1,6 @@ class PostsFake attr_reader :people_hash, :post_fakes - delegate :length, :each, :to_ary, :to => :post_fakes + delegate :length, :each, :to_ary, :last, :to => :post_fakes def initialize(posts) author_ids = [] diff --git a/public/javascripts/infinite-scroll.js b/public/javascripts/infinite-scroll.js index 9ec191d41..6f0b239df 100644 --- a/public/javascripts/infinite-scroll.js +++ b/public/javascripts/infinite-scroll.js @@ -7,8 +7,11 @@ var InfiniteScroll = { itemSelector : ".stream_element", // selector for all items you'll retrieve pathParse : function( pathStr, nextPage ){ + console.log(pathStr); + console.log(nextPage); var newPath = pathStr.replace("?", "?only_posts=true&"); - return newPath.replace( "page=2", "page=" + nextPage); + var last_time = $('#main_stream .stream_element').last().find('time.timeago').attr('integer'); + return newPath.replace( /max_time=\d+/, 'max_time=' + last_time); }, bufferPx: 500, debug: false, diff --git a/public/javascripts/widgets/directionDetector.js b/public/javascripts/widgets/directionDetector.js index e6aeafee4..e4817ece0 100644 --- a/public/javascripts/widgets/directionDetector.js +++ b/public/javascripts/widgets/directionDetector.js @@ -8,9 +8,9 @@ Diaspora.widgets.add("directionDetector", function() { this.start = function() { Diaspora.widgets.directionDetector.updateBinds(); - InfiniteScroll.postScrollCallback = function() { + InfiniteScroll.postScroll(function() { Diaspora.widgets.directionDetector.updateBinds(); - } + }); }; this.isRTL = function(str) { @@ -41,7 +41,7 @@ Diaspora.widgets.add("directionDetector", function() { this.cleaner = new RegExp('@[^ ]+|^RT[: ]{1}| RT | RT: |[♺♻:]+', 'g'); this.binds = []; - + this.updateBinds = function() { $.each(Diaspora.widgets.directionDetector.binds, function(i, v) {v.unbind('keyup', Diaspora.widgets.directionDetector.updateDirection);}); Diaspora.widgets.directionDetector.binds = []; diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 90cb10d42..854dc74ca 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -66,7 +66,7 @@ describe 'a user receives a post' do bob.dispatch_post(sm, :to => bob.aspects.first) end - alice.raw_visible_posts.count.should == 1 + alice.visible_posts.count.should == 1 end context 'mentions' do @@ -158,14 +158,14 @@ describe 'a user receives a post' do end it "adds a received post to the the contact" do - @user1.raw_visible_posts.include?(@status_message).should be_true + @user1.visible_posts.include?(@status_message).should be_true @contact.posts.include?(@status_message).should be_true end it 'removes posts upon disconnecting' do @user1.disconnect(@contact) @user1.reload - @user1.raw_visible_posts.should_not include @status_message + @user1.visible_posts.should_not include @status_message end context 'dependant delete' do @@ -243,7 +243,7 @@ describe 'a user receives a post' do end it 'should correctly attach the user already on the pod' do - @user2.reload.raw_visible_posts.size.should == 1 + @user2.reload.visible_posts.size.should == 1 post_in_db = StatusMessage.find(@post.id) post_in_db.comments.should == [] receive_with_zord(@user2, @user1.person, @xml) @@ -270,7 +270,7 @@ describe 'a user receives a post' do end } - @user2.reload.raw_visible_posts.size.should == 1 + @user2.reload.visible_posts.size.should == 1 post_in_db = StatusMessage.find(@post.id) post_in_db.comments.should == [] @@ -341,7 +341,7 @@ describe 'a user receives a post' do zord = Postzord::Receiver.new(@user2, :salmon_xml => salmon_xml) zord.perform - @user2.raw_visible_posts.include?(post).should be_true + @user2.visible_posts.include?(post).should be_true end end diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index b089fc603..5c1b3365a 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -46,7 +46,7 @@ describe 'making sure the spec runner works' do it 'allows posting after running' do message = @user1.post(:status_message, :text => "Connection!", :to => @aspect1.id) - @user2.reload.raw_visible_posts.should include message + @user2.reload.visible_posts.should include message end end diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index f05c6ac17..f6636fb45 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -30,7 +30,7 @@ describe "attack vectors" do zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml) zord.perform - user.raw_visible_posts.include?(post_from_non_contact).should be_false + user.visible_posts.include?(post_from_non_contact).should be_false Post.count.should == post_count end @@ -49,7 +49,7 @@ describe "attack vectors" do zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml) zord.perform - user3.reload.raw_visible_posts.should_not include(StatusMessage.find(original_message.id)) + user3.reload.visible_posts.should_not include(StatusMessage.find(original_message.id)) end context 'malicious contact attack vector' do @@ -89,10 +89,10 @@ describe "attack vectors" do zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml) zord.perform - }.should_not change{user.reload.raw_visible_posts.count} + }.should_not change{user.reload.visible_posts.count} original_message.reload.text.should == "store this!" - user.raw_visible_posts.first.text.should == "store this!" + user.visible_posts.first.text.should == "store this!" end end it 'should not overwrite another persons profile profile' do @@ -119,7 +119,7 @@ describe "attack vectors" do zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml) zord.perform - user.raw_visible_posts.count.should == 1 + user.visible_posts.count.should == 1 StatusMessage.count.should == 1 ret = Retraction.new @@ -132,7 +132,7 @@ describe "attack vectors" do zord.perform StatusMessage.count.should == 1 - user.raw_visible_posts.count.should == 1 + user.visible_posts.count.should == 1 end it "disregards retractions for non-existent posts that are from someone other than the post's author" do @@ -163,7 +163,7 @@ describe "attack vectors" do zord.perform - user.raw_visible_posts.count.should == 1 + user.visible_posts.count.should == 1 ret = Retraction.new ret.post_guid = original_message.guid @@ -177,7 +177,7 @@ describe "attack vectors" do zord.perform }.should_not change(StatusMessage, :count) - user.reload.raw_visible_posts.count.should == 1 + user.reload.visible_posts.count.should == 1 end it 'it should not allow you to send retractions for other people' do diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 2e98e2690..a8de3937c 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -275,9 +275,9 @@ describe Diaspora::UserModules::Connecting do end it "deletes the disconnected user's posts from visible_posts" do - bob.reload.raw_visible_posts.include?(@message).should be_true + bob.reload.visible_posts.include?(@message).should be_true bob.disconnect bob.contact_for(alice.person) - bob.reload.raw_visible_posts.include?(@message).should be_false + bob.reload.visible_posts.include?(@message).should be_false end end diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 1d04b741f..3b013233d 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -28,8 +28,8 @@ describe User do it 'saves post into visible post ids' do proc { user.add_to_streams(@post, @aspects) - }.should change{user.raw_visible_posts(:by_members_of => @aspects).length}.by(1) - user.raw_visible_posts(:by_members_of => @aspects).should include @post + }.should change{user.visible_posts(:by_members_of => @aspects).length}.by(1) + user.visible_posts(:by_members_of => @aspects).should include @post end it 'saves post into each aspect in aspect_ids' do diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 189802a45..dfe21fb87 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -11,7 +11,7 @@ describe User do @eves_aspect = eve.aspects.first end - describe "#raw_visible_posts" do + describe "#visible_posts" do it "returns all the posts the user can see" do connect_users(eve, @eves_aspect, alice, @alices_aspect) self_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id) @@ -19,7 +19,7 @@ describe User do dogs = eve.aspects.create(:name => "dogs") invisible_post = eve.post(:status_message, :text => "foobar", :to => dogs.id) - stream = alice.raw_visible_posts + stream = alice.visible_posts stream.should include(self_post) stream.should include(visible_post) stream.should_not include(invisible_post) @@ -31,28 +31,35 @@ describe User do (1..25).each do |n| [alice, bob, eve].each do |u| post = u.post :status_message, :text => "#{u.username} - #{n}", :to => u.aspects.first.id - post.created_at = post.created_at + time_interval - post.updated_at = post.updated_at + time_interval + post.created_at = post.created_at - time_interval + post.updated_at = post.updated_at - time_interval post.save time_interval += 1000 end end end it 'works' do #This is in one spec to save time - bob.raw_visible_posts.length.should == 15 #it returns 15 by default - bob.raw_visible_posts.should == bob.raw_visible_posts(:by_members_of => bob.aspects.map{|a| a.id}) # it is the same when joining through aspects - bob.raw_visible_posts.sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.raw_visible_posts.map{|p| p.id}.reverse #it is sorted updated_at desc by default + bob.visible_posts.length.should == 15 #it returns 15 by default + bob.visible_posts.should == bob.visible_posts(:by_members_of => bob.aspects.map{|a| a.id}) # it is the same when joining through aspects + bob.visible_posts.sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.visible_posts.map{|p| p.id}.reverse #it is sorted updated_at desc by default opts = {:limit => 40} - bob.raw_visible_posts(opts).length.should == 40 #it takes a limit - bob.raw_visible_posts(opts).should == bob.raw_visible_posts(opts.merge(:by_members_of => bob.aspects.map{|a| a.id})) - bob.raw_visible_posts(opts).sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.raw_visible_posts(opts).map{|p| p.id}.reverse + bob.visible_posts(opts).length.should == 40 #it takes a limit + bob.visible_posts(opts).should == bob.visible_posts(opts.merge(:by_members_of => bob.aspects.map{|a| a.id})) + bob.visible_posts(opts).sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.visible_posts(opts).map{|p| p.id}.reverse - opts = {:page => 2} - bob.raw_visible_posts(opts).length.should == 15 - bob.raw_visible_posts(opts).map{|p| p.id}.should == bob.raw_visible_posts(opts.merge(:by_members_of => bob.aspects.map{|a| a.id})).map{|p| p.id} - bob.raw_visible_posts(opts).sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.raw_visible_posts(opts).map{|p| p.id}.reverse - bob.raw_visible_posts(opts).map{|p|p.id}.should == bob.raw_visible_posts(:limit => 40)[15...30].map{|p|p.id} #pagination should return the right posts + last_time_of_last_page = bob.visible_posts.last.updated_at + opts = {:max_time => last_time_of_last_page} + bob.visible_posts(opts).length.should == 15 + bob.visible_posts(opts).map{|p| p.id}.should == bob.visible_posts(opts.merge(:by_members_of => bob.aspects.map{|a| a.id})).map{|p| p.id} + bob.visible_posts(opts).sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.visible_posts(opts).map{|p| p.id}.reverse + bob.visible_posts(opts).map{|p|p.id}.should == bob.visible_posts(:limit => 40)[15...30].map{|p|p.id} #pagination should return the right posts + + opts = {:max_time => last_time_of_last_page.to_i} + bob.visible_posts(opts).length.should == 15 + bob.visible_posts(opts).map{|p| p.id}.should == bob.visible_posts(opts.merge(:by_members_of => bob.aspects.map{|a| a.id})).map{|p| p.id} + bob.visible_posts(opts).sort_by{|p| p.updated_at}.map{|p| p.id}.should == bob.visible_posts(opts).map{|p| p.id}.reverse + bob.visible_posts(opts).map{|p|p.id}.should == bob.visible_posts(:limit => 40)[15...30].map{|p|p.id} #pagination should return the right posts end end end @@ -72,7 +79,7 @@ describe User do describe "#visible_posts" do it "queries by person id" do - query = eve.raw_visible_posts.where(:author_id => eve.person.id) + query = eve.visible_posts.where(:author_id => eve.person.id) query.include?(@status_message1).should == true query.include?(@status_message2).should == true query.include?(@status_message3).should == false @@ -81,7 +88,7 @@ describe User do end it "selects public posts" do - query = eve.raw_visible_posts.where(:public => true) + query = eve.visible_posts.where(:public => true) query.include?(@status_message1).should == false query.include?(@status_message2).should == true query.include?(@status_message3).should == true @@ -90,7 +97,7 @@ describe User do end it "selects non public posts" do - query = eve.raw_visible_posts.where(:public => false) + query = eve.visible_posts.where(:public => false) query.include?(@status_message1).should == true query.include?(@status_message2).should == false query.include?(@status_message3).should == false @@ -99,13 +106,13 @@ describe User do end it "selects by message contents" do - query = eve.raw_visible_posts.where(:text=> "hi") + query = eve.visible_posts.where(:text=> "hi") query.should == [@status_message1] end it "does not return pending posts" do @pending_status_message.pending.should be_true - eve.raw_visible_posts.should_not include @pending_status_message + eve.visible_posts.should_not include @pending_status_message end it '#find_visible_post_by_id' do