diff --git a/app/models/user.rb b/app/models/user.rb index 73c273530..29bb19607 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -207,7 +207,7 @@ class User < ActiveRecord::Base comment = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on]) - + comment.set_guid #sign comment as commenter comment.creator_signature = comment.sign_with_key(self.encryption_key) diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 01744703b..ace5c35f6 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -11,8 +11,8 @@ module Diaspora end def raw_visible_posts - Post.joins(:aspects).where(:pending => false, - :aspects => {:user_id => self.id}) + Post.joins(:post_visibilities => :aspect).where(:pending => false, + :aspects => {:user_id => self.id}).select('DISTINCT `posts`.*') end def visible_posts( opts = {} ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index e812b47d1..f059399a8 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -213,9 +213,7 @@ describe Comment do it 'should attach the creator signature if the user is commenting' do comment = user.comment "Yeah, it was great", :on => @remote_message - pp comment.signable_string @remote_message.comments.reset - pp @remote_message.comments.first @remote_message.comments.first.signature_valid?.should be_true end diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 8b8fd6e1c..294a1cbf9 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -16,13 +16,12 @@ describe Retraction do it 'should have a post id after serialization' do retraction = Retraction.for(post) xml = retraction.to_xml.to_s - xml.include?(post.id.to_s).should == true + xml.include?(post.guid.to_s).should == true end end describe 'dispatching' do - it 'should dispatch a message on delete' do - Factory.create(:person) + it 'should dispatch a message on destroy' do MessageHandler.should_receive :add_post_request post.destroy end diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 0f1ab15f9..ebd315daf 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -26,8 +26,10 @@ describe User do it 'saves post into visible post ids' do proc { + pp user.raw_visible_posts user.add_to_streams(@post, @aspect_ids) - }.should change(user.raw_visible_posts, :count).by(1) + pp user.raw_visible_posts + }.should change{user.raw_visible_posts.count}.by(1) user.reload.raw_visible_posts.should include @post end @@ -46,7 +48,7 @@ describe User do describe '#aspects_from_ids' do it 'returns a list of all valid aspects a user can post to' do aspect_ids = Aspect.all.map(&:id) - user.aspects_from_ids(aspect_ids).should =~ [aspect, aspect1] + user.aspects_from_ids(aspect_ids).should =~ user.aspects end it "lets you post to your own aspects" do user.aspects_from_ids([aspect.id]).should == [aspect] diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a66ed0516..a1e2eacc2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -347,6 +347,8 @@ describe User do it 'should send retractions to remote poeple' do user2.delete + user2.person.owner_id = nil + user2.person.save user.activate_contact(user2.person, aspect) user.should_receive(:disconnect).once @@ -355,7 +357,9 @@ describe User do it 'should disconnect local people' do connect_users(user, aspect, user2, aspect2) - lambda {user.destroy}.should change{user2.reload.contacts.count}.by(-1) + lambda { + user.destroy + }.should change{user2.reload.contacts.count}.by(-1) end end end