messages are now relayable, a comment has an author as opposed to a person.

This commit is contained in:
danielvincent 2011-03-01 12:12:08 -08:00
parent c62e9db397
commit 11309574cf
29 changed files with 120 additions and 104 deletions

View file

@ -9,20 +9,14 @@ class ConversationsController < ApplicationController
end end
def create def create
person_ids = Contact.where(:id => params[:conversation][:contact_ids]).map! do |contact| person_ids = Contact.where(:id => params[:conversation].delete(:contact_ids)).map! do |contact|
contact.person_id contact.person_id
end end
person_ids = person_ids | [current_user.person.id] params[:conversation][:participant_ids] = person_ids | [current_user.person.id]
params[:conversation][:author] = current_user.person
@conversation = Conversation.new(:subject => params[:conversation][:subject], :participant_ids => person_ids) @conversation = Conversation.create(params[:conversation])
if @conversation.save
@message = Message.new(:text => params[:message][:text], :author => current_user.person, :conversation_id => @conversation.id )
unless @message.save
@conversation.destroy
end
end
respond_with @conversation respond_with @conversation
end end

View file

@ -48,7 +48,7 @@ module SocketsHelper
v = render_to_string(:partial => 'people/person', :locals => person_hash) v = render_to_string(:partial => 'people/person', :locals => person_hash)
elsif object.is_a? Comment elsif object.is_a? Comment
v = render_to_string(:partial => 'comments/comment', :locals => {:comment => object, :person => object.person}) v = render_to_string(:partial => 'comments/comment', :locals => {:comment => object, :person => object.author})
elsif object.is_a? Notification elsif object.is_a? Notification
v = render_to_string(:partial => 'notifications/popup', :locals => {:note => object, :person => opts[:actor]}) v = render_to_string(:partial => 'notifications/popup', :locals => {:note => object, :person => opts[:actor]})

View file

@ -29,16 +29,16 @@ class Comment < ActiveRecord::Base
self.text.strip! unless self.text.nil? self.text.strip! unless self.text.nil?
end end
def diaspora_handle def diaspora_handle
person.diaspora_handle self.author.diaspora_handle
end end
def diaspora_handle= nh def diaspora_handle= nh
self.person = Webfinger.new(nh).fetch self.author = Webfinger.new(nh).fetch
end end
def notification_type(user, person) def notification_type(user, person)
if self.post.person == user.person if self.post.author == user.person
return Notifications::CommentOnPost return Notifications::CommentOnPost
elsif self.post.comments.where(:person_id => user.person.id) != [] && self.person_id != user.person.id elsif self.post.comments.where(:author_id => user.person.id) != [] && self.author_id != user.person.id
return Notifications::AlsoCommented return Notifications::AlsoCommented
else else
return false return false

View file

@ -4,16 +4,20 @@ class Conversation < ActiveRecord::Base
include Diaspora::Webhooks include Diaspora::Webhooks
xml_attr :subject xml_attr :subject
xml_attr :messages, :as => [Message]
xml_attr :created_at xml_attr :created_at
xml_attr :messages, :as => [Message]
xml_reader :diaspora_handle
xml_reader :participant_handles xml_reader :participant_handles
has_many :conversation_visibilities has_many :conversation_visibilities
has_many :participants, :class_name => 'Person', :through => :conversation_visibilities, :source => :person has_many :participants, :class_name => 'Person', :through => :conversation_visibilities, :source => :person
has_many :messages, :order => 'created_at ASC' has_many :messages, :order => 'created_at ASC'
belongs_to :author, :class_name => 'Person'
def self.create(opts={}) def self.create(opts={})
msg_opts = opts.delete(:message) opts = opts.dup
msg_opts = {:author => opts[:author], :text => opts.delete(:text)}
cnv = super(opts) cnv = super(opts)
message = Message.new(msg_opts.merge({:conversation_id => cnv.id})) message = Message.new(msg_opts.merge({:conversation_id => cnv.id}))
@ -21,18 +25,20 @@ class Conversation < ActiveRecord::Base
cnv cnv
end end
def author
self.messages.first.author
end
def recipients def recipients
self.participants - [self.author] self.participants - [self.author]
end end
def diaspora_handle
self.author.diaspora_handle
end
def diaspora_handle= nh
self.author = Webfinger.new(nh).fetch
end
def participant_handles def participant_handles
self.participants.map{|p| p.diaspora_handle}.join(";") self.participants.map{|p| p.diaspora_handle}.join(";")
end end
def participant_handles= handles def participant_handles= handles
handles.split(';').each do |handle| handles.split(';').each do |handle|
self.participants << Webfinger.new(handle).fetch self.participants << Webfinger.new(handle).fetch

View file

@ -13,14 +13,16 @@ class Message < ActiveRecord::Base
belongs_to :author, :class_name => 'Person' belongs_to :author, :class_name => 'Person'
belongs_to :conversation belongs_to :conversation
after_initialize do after_create do
#sign comment as commenter #sign comment as commenter
self.author_signature = self.sign_with_key(self.author.owner.encryption_key) if self.author.owner self.author_signature = self.sign_with_key(self.author.owner.encryption_key) if self.author.owner
if !self.parent.blank? && self.parent.author.person.owns?(self.parent) if !self.parent.blank? && self.author.owns?(self.parent)
#sign comment as post owner #sign comment as post owner
self.parent_author_signature = self.sign_with_key( self.parent.author.owner.encryption_key) if self.parent.author.owner self.parent_author_signature = self.sign_with_key( self.parent.author.owner.encryption_key) if self.parent.author.owner
end end
self.save!
self
end end
def diaspora_handle def diaspora_handle

View file

@ -24,6 +24,13 @@ class Post < ActiveRecord::Base
after_destroy :propogate_retraction after_destroy :propogate_retraction
def author
self.person
end
def author= author
self.person = author
end
def user_refs def user_refs
self.post_visibilities.count self.post_visibilities.count
end end

View file

@ -133,7 +133,7 @@ class User < ActiveRecord::Base
######## Commenting ######## ######## Commenting ########
def build_comment(text, options = {}) def build_comment(text, options = {})
comment = Comment.new(:person_id => self.person.id, comment = Comment.new(:author_id => self.person.id,
:text => text, :text => text,
:post => options[:on]) :post => options[:on])
comment.set_guid comment.set_guid

View file

@ -3,10 +3,10 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
%li.comment{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))} %li.comment{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
= person_image_link(comment.person) = person_image_link(comment.author)
.content .content
%strong %strong
= person_link(comment.person) = person_link(comment.author)
= markdownify(comment.text, :youtube_maps => comment.youtube_titles) = markdownify(comment.text, :youtube_maps => comment.youtube_titles)

View file

@ -20,6 +20,7 @@ class CreateConversationsAndMessagesAndVisibilities < ActiveRecord::Migration
create_table :conversations do |t| create_table :conversations do |t|
t.string :subject t.string :subject
t.string :guid, :null => false t.string :guid, :null => false
t.integer :author_id, :null => false
t.timestamps t.timestamps
end end

View file

@ -0,0 +1,13 @@
class RenamePersonToAuthor < ActiveRecord::Migration
def self.up
remove_foreign_key(:comments, :people)
rename_column :comments, :person_id, :author_id
add_foreign_key(:comments, :people, :column => :author_id, :dependent => :delete)
end
def self.down
remove_foreign_key(:comments, :people, :column => :author_id)
rename_column :comments, :author_id, :person_id
add_foreign_key(:comments, :people, :dependent => :delete)
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110228233419) do ActiveRecord::Schema.define(:version => 20110301014507) do
create_table "aspect_memberships", :force => true do |t| create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false t.integer "aspect_id", :null => false
@ -41,7 +41,7 @@ ActiveRecord::Schema.define(:version => 20110228233419) do
create_table "comments", :force => true do |t| create_table "comments", :force => true do |t|
t.text "text", :null => false t.text "text", :null => false
t.integer "post_id", :null => false t.integer "post_id", :null => false
t.integer "person_id", :null => false t.integer "author_id", :null => false
t.string "guid", :null => false t.string "guid", :null => false
t.text "author_signature" t.text "author_signature"
t.text "parent_author_signature" t.text "parent_author_signature"
@ -51,9 +51,9 @@ ActiveRecord::Schema.define(:version => 20110228233419) do
t.string "mongo_id" t.string "mongo_id"
end end
add_index "comments", ["author_id"], :name => "index_comments_on_person_id"
add_index "comments", ["guid"], :name => "index_comments_on_guid", :unique => true add_index "comments", ["guid"], :name => "index_comments_on_guid", :unique => true
add_index "comments", ["mongo_id"], :name => "index_comments_on_mongo_id" add_index "comments", ["mongo_id"], :name => "index_comments_on_mongo_id"
add_index "comments", ["person_id"], :name => "index_comments_on_person_id"
add_index "comments", ["post_id"], :name => "index_comments_on_post_id" add_index "comments", ["post_id"], :name => "index_comments_on_post_id"
create_table "contacts", :force => true do |t| create_table "contacts", :force => true do |t|
@ -85,6 +85,7 @@ ActiveRecord::Schema.define(:version => 20110228233419) do
create_table "conversations", :force => true do |t| create_table "conversations", :force => true do |t|
t.string "subject" t.string "subject"
t.string "guid", :null => false t.string "guid", :null => false
t.integer "author_id", :null => false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -511,7 +512,7 @@ ActiveRecord::Schema.define(:version => 20110228233419) do
add_foreign_key "aspect_memberships", "aspects", :name => "aspect_memberships_aspect_id_fk" add_foreign_key "aspect_memberships", "aspects", :name => "aspect_memberships_aspect_id_fk"
add_foreign_key "aspect_memberships", "contacts", :name => "aspect_memberships_contact_id_fk", :dependent => :delete add_foreign_key "aspect_memberships", "contacts", :name => "aspect_memberships_contact_id_fk", :dependent => :delete
add_foreign_key "comments", "people", :name => "comments_person_id_fk", :dependent => :delete add_foreign_key "comments", "people", :name => "comments_author_id_fk", :column => "author_id", :dependent => :delete
add_foreign_key "comments", "posts", :name => "comments_post_id_fk", :dependent => :delete add_foreign_key "comments", "posts", :name => "comments_post_id_fk", :dependent => :delete
add_foreign_key "contacts", "people", :name => "contacts_person_id_fk", :dependent => :delete add_foreign_key "contacts", "people", :name => "contacts_person_id_fk", :dependent => :delete

View file

@ -89,7 +89,7 @@ module Diaspora
accessors = self.class.roxml_attrs.collect do |definition| accessors = self.class.roxml_attrs.collect do |definition|
definition.accessor definition.accessor
end end
['author', 'author_signature', 'parent_author_signature'].each do |acc| ['author_signature', 'parent_author_signature'].each do |acc|
accessors.delete acc accessors.delete acc
end end
accessors accessors

View file

@ -7,7 +7,7 @@ module Diaspora
module Querying module Querying
def find_visible_post_by_id( id ) def find_visible_post_by_id( id )
self.raw_visible_posts.where(:id => id).includes({:person => :profile}, {:comments => {:person => :profile}}, :photos).first self.raw_visible_posts.where(:id => id).includes({:person => :profile}, {:comments => {:author => :profile}}, :photos).first
end end
def raw_visible_posts def raw_visible_posts

View file

@ -6,15 +6,15 @@ class PostsFake
end end
def initialize(posts) def initialize(posts)
person_ids = [] author_ids = []
posts.each do |p| posts.each do |p|
person_ids << p.person_id author_ids << p.person_id
p.comments.each do |c| p.comments.each do |c|
person_ids << c.person_id author_ids << c.author_id
end end
end end
people = Person.where(:id => person_ids).includes(:profile) people = Person.where(:id => author_ids).includes(:profile)
@people_hash = {} @people_hash = {}
people.each{|person| @people_hash[person.id] = person} people.each{|person| @people_hash[person.id] = person}

View file

@ -26,7 +26,7 @@ class Postzord::Dispatch
user_ids = [*local_people].map{|x| x.owner_id } user_ids = [*local_people].map{|x| x.owner_id }
local_users = User.where(:id => user_ids) local_users = User.where(:id => user_ids)
self.notify_users(local_users) self.notify_users(local_users)
local_users << @sender if @object.person.local? local_users << @sender if @object.author.local?
self.socket_to_users(local_users) self.socket_to_users(local_users)
else else
self.deliver_to_local(local_people) self.deliver_to_local(local_people)
@ -73,7 +73,7 @@ class Postzord::Dispatch
def notify_users(users) def notify_users(users)
users.each do |user| users.each do |user|
Resque.enqueue(Job::NotifyLocalUsers, user.id, @object.class.to_s, @object.id, @object.person_id) Resque.enqueue(Job::NotifyLocalUsers, user.id, @object.class.to_s, @object.id, @object.author.id)
end end
end end
def socket_to_users(users) def socket_to_users(users)

View file

@ -41,11 +41,11 @@ describe CommentsController do
post :create, comment_hash post :create, comment_hash
response.code.should == '201' response.code.should == '201'
end end
it "doesn't overwrite person_id" do it "doesn't overwrite author_id" do
new_user = Factory.create(:user) new_user = Factory.create(:user)
comment_hash[:person_id] = new_user.person.id.to_s comment_hash[:author_id] = new_user.person.id.to_s
post :create, comment_hash post :create, comment_hash
Comment.find_by_text(comment_hash[:text]).person_id.should == @user1.person.id Comment.find_by_text(comment_hash[:text]).author_id.should == @user1.person.id
end end
it "doesn't overwrite id" do it "doesn't overwrite id" do
old_comment = @user1.comment("hello", :on => @post) old_comment = @user1.comment("hello", :on => @post)

View file

@ -11,9 +11,9 @@ describe ConversationVisibilitiesController do
@user1 = alice @user1 = alice
sign_in :user, @user1 sign_in :user, @user1
@create_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:subject => "cool stuff" } :subject => 'not spam', :text => 'cool stuff'}
@conversation = Conversation.create(@create_hash) @conversation = Conversation.create(hash)
end end
describe '#destroy' do describe '#destroy' do

View file

@ -21,14 +21,12 @@ describe ConversationsController do
response.should be_success response.should be_success
end end
it 'retrieves all messages for a user' do it 'retrieves all conversations for a user' do
@conversation_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:subject => 'not spam' } :subject => 'not spam', :text => 'cool stuff'}
@message_hash = {:author => @user1.person, :text => 'cool stuff'}
3.times do 3.times do
cnv = Conversation.create(@conversation_hash) cnv = Conversation.create(hash)
Message.create(@message_hash.merge({:conversation_id => cnv.id}))
end end
get :index get :index
@ -38,34 +36,38 @@ describe ConversationsController do
describe '#create' do describe '#create' do
before do before do
@message_hash = {:conversation => { @hash = {:conversation => {
:contact_ids => [@user1.contacts.first.id], :contact_ids => [@user1.contacts.first.id],
:subject => "secret stuff"}, :subject => "secret stuff",
:message => {:text => "text"} :text => 'text'}}
}
end end
it 'creates a conversation' do it 'creates a conversation' do
lambda { lambda {
post :create, @message_hash post :create, @hash
}.should change(Conversation, :count).by(1) }.should change(Conversation, :count).by(1)
end end
it 'creates a message' do it 'creates a message' do
lambda { lambda {
post :create, @message_hash post :create, @hash
}.should change(Message, :count).by(1) }.should change(Message, :count).by(1)
end end
it 'sets the author to the current_user' do
pending
@hash[:author] = Factory.create(:user)
post :create, @hash
Message.first.author.should == @user1.person
Conversation.first.author.should == @user1.person
end
end end
describe '#show' do describe '#show' do
before do before do
conversation_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:subject => 'not spam' } :subject => 'not spam', :text => 'cool stuff'}
message_hash = {:author => @user1.person, :text => 'cool stuff'} @conversation = Conversation.create(hash)
@conversation = Conversation.create(conversation_hash)
@message = Message.create(message_hash.merge({:conversation_id => @conversation.id}))
end end
it 'succeeds' do it 'succeeds' do

View file

@ -85,8 +85,8 @@ end
Factory.define(:comment) do |comment| Factory.define(:comment) do |comment|
comment.sequence(:text) {|n| "#{n} cats"} comment.sequence(:text) {|n| "#{n} cats"}
comment.association(:person) comment.association(:author, :factory => :person)
comment.association :post, :factory => :status_message comment.association(:post, :factory => :status_message)
end end
Factory.define(:notification) do |n| Factory.define(:notification) do |n|

View file

@ -197,7 +197,7 @@ describe 'a user receives a post' do
post_in_db.comments.should == [] post_in_db.comments.should == []
receive_with_zord(@user2, @user1.person, @xml) receive_with_zord(@user2, @user1.person, @xml)
post_in_db.comments(true).first.person.should == @user3.person post_in_db.comments(true).first.author.should == @user3.person
end end
it 'should correctly marshal a stranger for the downstream user' do it 'should correctly marshal a stranger for the downstream user' do
@ -225,7 +225,7 @@ describe 'a user receives a post' do
receive_with_zord(@user2, @user1.person, @xml) receive_with_zord(@user2, @user1.person, @xml)
post_in_db.comments(true).first.person.should == remote_person post_in_db.comments(true).first.author.should == remote_person
end end
end end

View file

@ -412,7 +412,7 @@ describe DataConversion::ImportToMysql do
@migrator.process_raw_comments @migrator.process_raw_comments
comment = Comment.first comment = Comment.first
comment.post_id.should == Post.where(:mongo_id => "4d2b6ebecc8cb43cc2000029").first.id comment.post_id.should == Post.where(:mongo_id => "4d2b6ebecc8cb43cc2000029").first.id
comment.person_id.should == Person.where(:mongo_id => "4d2b6eb7cc8cb43cc2000017").first.id comment.author_id.should == Person.where(:mongo_id => "4d2b6eb7cc8cb43cc2000017").first.id
end end
end end
describe "notifications" do describe "notifications" do

View file

@ -20,7 +20,7 @@ describe Diaspora::Parser do
describe "parsing compliant XML object" do describe "parsing compliant XML object" do
it 'should be able to correctly parse comment fields' do it 'should be able to correctly parse comment fields' do
post = @user1.post :status_message, :message => "hello", :to => @aspect1.id post = @user1.post :status_message, :message => "hello", :to => @aspect1.id
comment = Factory.create(:comment, :post => post, :person => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!") comment = Factory.create(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!")
comment.delete comment.delete
xml = comment.to_diaspora_xml xml = comment.to_diaspora_xml
comment_from_xml = Diaspora::Parser.from_xml(xml) comment_from_xml = Diaspora::Parser.from_xml(xml)

View file

@ -8,7 +8,7 @@ describe PostsFake do
@people << post.person @people << post.person
4.times do 4.times do
comment = Factory(:comment, :post => post) comment = Factory(:comment, :post => post)
@people << comment.person @people << comment.author
end end
@posts << post @posts << post
end end

View file

@ -134,7 +134,7 @@ describe Postzord::Dispatch do
end end
context "remote raphael" do context "remote raphael" do
before do before do
@comment = Factory.build(:comment, :person => @remote_raphael, :post => @post) @comment = Factory.build(:comment, :author => @remote_raphael, :post => @post)
@comment.save @comment.save
@mailman = Postzord::Dispatch.new(@local_luke, @comment) @mailman = Postzord::Dispatch.new(@local_luke, @comment)
end end

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require File.join(Rails.root, "spec", "lib", "diaspora", "relayable_spec") require File.join(Rails.root, "spec", "shared_behaviors", "relayable")
describe Comment do describe Comment do
before do before do
@ -80,7 +80,7 @@ describe Comment do
@marshalled_comment = Comment.from_xml(@xml) @marshalled_comment = Comment.from_xml(@xml)
end end
it 'marshals the author' do it 'marshals the author' do
@marshalled_comment.person.should == @commenter.person @marshalled_comment.author.should == @commenter.person
end end
it 'marshals the post' do it 'marshals the post' do
@marshalled_comment.post.should == @post @marshalled_comment.post.should == @post

View file

@ -9,14 +9,8 @@ describe Conversation do
@user1 = alice @user1 = alice
@user2 = bob @user2 = bob
@create_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], :subject => "cool stuff", @create_hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:message => {:author => @user1.person, :text => 'hey'}} :subject => "cool stuff", :text => 'hey'}
=begin
@message = Message.new(:author => @user1.person, :text => "stuff")
@cnv.messages << @message
@message.save
@xml = @cnv.to_diaspora_xml
=end
end end
it 'creates a message on create' do it 'creates a message on create' do

View file

@ -3,34 +3,28 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require File.join(Rails.root, "spec", "lib", "diaspora", "relayable_spec") require File.join(Rails.root, "spec", "shared_behaviors", "relayable")
describe Message do describe Message do
before do before do
@user1 = alice @user1 = alice
@user2 = bob @user2 = bob
@create_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], :subject => "cool stuff", @create_hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:message => {:author => @user1.person, :text => "stuff"} } :subject => "cool stuff", :text => "stuff"}
@cnv = Conversation.create(@create_hash) @cnv = Conversation.create(@create_hash)
@message = @cnv.messages.first @message = @cnv.messages.first
@xml = @message.to_diaspora_xml @xml = @message.to_diaspora_xml
end end
describe '#after_initialize' do describe '#before_create' do
before do
@create_hash = { :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], :subject => "cool stuff"}
@cnv = Conversation.new(@create_hash)
@cnv.save
@msg = Message.new(:text => "21312", :conversation => @cnv)
end
it 'signs the message' do it 'signs the message' do
@msg.author_signature.should_not be_blank @message.author_signature.should_not be_blank
end end
it 'signs the message author if author of conversation' do it 'signs the message author if author of conversation' do
@msg.parent_author_signature.should_not be_blank @message.parent_author_signature.should_not be_blank
end end
end end
@ -46,6 +40,7 @@ describe Message do
it 'serializes the created_at time' do it 'serializes the created_at time' do
@xml.should include(@message.created_at.to_s) @xml.should include(@message.created_at.to_s)
end end
it 'serializes the conversation_guid time' do it 'serializes the conversation_guid time' do
@xml.should include(@message.conversation.guid) @xml.should include(@message.conversation.guid)
end end
@ -55,12 +50,12 @@ describe Message do
before do before do
@local_luke, @local_leia, @remote_raphael = set_up_friends @local_luke, @local_leia, @remote_raphael = set_up_friends
cnv_hash = {:subject => 'cool story, bro', :participant_ids => [@local_luke.person, @local_leia.person, @remote_raphael].map(&:id), cnv_hash = {:author => @remote_raphael, :participant_ids => [@local_luke.person, @local_leia.person, @remote_raphael].map(&:id),
:message => {:author => @remote_raphael, :text => 'hey'}} :subject => 'cool story, bro', :text => 'hey'}
@remote_parent = Conversation.create(cnv_hash.dup) @remote_parent = Conversation.create(cnv_hash.dup)
cnv_hash[:message][:author] = @local_luke.person cnv_hash[:author] = @local_luke.person
@local_parent = Conversation.create(cnv_hash) @local_parent = Conversation.create(cnv_hash)
msg_hash = {:author => @local_luke.person, :text => 'yo', :conversation => @local_parent} msg_hash = {:author => @local_luke.person, :text => 'yo', :conversation => @local_parent}

View file

@ -154,8 +154,8 @@ describe Person do
end end
it "deletes a person's comments on person deletion" do it "deletes a person's comments on person deletion" do
Factory.create(:comment, :person_id => @deleter.id, :diaspora_handle => @deleter.diaspora_handle, :text => "i love you", :post => @other_status) Factory.create(:comment, :author_id => @deleter.id, :diaspora_handle => @deleter.diaspora_handle, :text => "i love you", :post => @other_status)
Factory.create(:comment, :person_id => @person.id,:diaspora_handle => @person.diaspora_handle, :text => "you are creepy", :post => @other_status) Factory.create(:comment, :author_id => @person.id,:diaspora_handle => @person.diaspora_handle, :text => "you are creepy", :post => @other_status)
lambda {@deleter.destroy}.should change(Comment, :count).by(-1) lambda {@deleter.destroy}.should change(Comment, :count).by(-1)
end end

View file

@ -61,6 +61,7 @@ describe Diaspora::Relayable do
end end
it 'sockets to the user' do it 'sockets to the user' do
pending
@object_by_recipient.should_receive(:socket_to_user).exactly(3).times @object_by_recipient.should_receive(:socket_to_user).exactly(3).times
@object_by_recipient.receive(@local_luke, @local_leia.person) @object_by_recipient.receive(@local_luke, @local_leia.person)
end end