Status message spec now passes

This commit is contained in:
Michael Sofaer and Raphael Sofaer 2010-12-23 12:56:49 -08:00
parent 2b7eeffd5b
commit 44093c9342
4 changed files with 13 additions and 6 deletions

View file

@ -29,6 +29,11 @@ class Post < ActiveRecord::Base
self.post_visibilities.count self.post_visibilities.count
end end
def diaspora_handle= nd
self.person = Person.where(:diaspora_handle => nd).first
write_attribute(:diaspora_handle, nd)
end
def self.diaspora_initialize params def self.diaspora_initialize params
new_post = self.new params.to_hash new_post = self.new params.to_hash
new_post.person = params[:person] new_post.person = params[:person]

View file

@ -112,7 +112,6 @@ ActiveRecord::Schema.define(:version => 0) do
t.string "diaspora_handle" t.string "diaspora_handle"
t.string "guid" t.string "guid"
t.boolean "pending", :default => false t.boolean "pending", :default => false
t.integer "user_refs", :default => 0
t.string "type" t.string "type"
t.text "message" t.text "message"
t.integer "status_message_id" t.integer "status_message_id"

View file

@ -32,8 +32,6 @@ module Diaspora
xml_author = (owns?(object.post)) ? object.diaspora_handle : object.post.person.diaspora_handle xml_author = (owns?(object.post)) ? object.diaspora_handle : object.post.person.diaspora_handle
else else
xml_author = object.diaspora_handle xml_author = object.diaspora_handle
pp xml_author
pp salmon_author
end end
if (salmon_author.diaspora_handle != xml_author) if (salmon_author.diaspora_handle != xml_author)
@ -158,9 +156,7 @@ module Diaspora
on_pod = existing_post(post) on_pod = existing_post(post)
log_string = "event=receive payload_type=#{post.class} sender=#{post.diaspora_handle} " log_string = "event=receive payload_type=#{post.class} sender=#{post.diaspora_handle} "
if on_pod if on_pod
puts "On pod"
if post_visible?(post) if post_visible?(post)
puts "visible"
if post.mutable? if post.mutable?
on_pod.caption = post.caption on_pod.caption = post.caption
on_pod.save! on_pod.save!
@ -183,7 +179,6 @@ module Diaspora
def add_post_to_aspects(post) def add_post_to_aspects(post)
Rails.logger.debug("event=add_post_to_aspects user_id=#{self.id} post_id=#{post.id}") Rails.logger.debug("event=add_post_to_aspects user_id=#{self.id} post_id=#{post.id}")
puts("event=add_post_to_aspects user_id=#{self.id} post_id=#{post.id}")
aspects = self.aspects_with_person(post.person) aspects = self.aspects_with_person(post.person)
aspects.each do |aspect| aspects.each do |aspect|

View file

@ -11,6 +11,14 @@ describe StatusMessage do
@aspect = @user.aspects.create(:name => "losers") @aspect = @user.aspects.create(:name => "losers")
end end
describe '#diaspora_handle=' do
it 'sets #person' do
person = Factory.create(:person)
post = Factory.create(:status_message, :person => @user.person)
post.diaspora_handle = person.diaspora_handle
post.person.should == person
end
end
it "should have either a message or at least one photo" do it "should have either a message or at least one photo" do
n = Factory.build(:status_message, :message => nil) n = Factory.build(:status_message, :message => nil)
n.valid?.should be_false n.valid?.should be_false