From f2e327d908802b12386bc3e2ca2621db7716ffe3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 13:27:42 -0700 Subject: [PATCH] User factory now works --- app/models/post.rb | 1 - app/models/retraction.rb | 1 - lib/diaspora/webhooks.rb | 1 - spec/factories.rb | 6 ++++-- spec/misc_spec.rb | 5 +++++ spec/models/retraction_spec.rb | 1 - 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6fc92d1ae..74fce8881 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -72,7 +72,6 @@ protected end def propagate_retraction - puts 'propagating retraction' Retraction.for(self).notify_people end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index a49282a0b..fcd461059 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -8,7 +8,6 @@ class Retraction retraction.post_id= object.id retraction.person_id = person_id_from(object) retraction.type = object.class.to_s - puts retraction.inspect retraction end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index de9a46900..929dff515 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -17,7 +17,6 @@ module Diaspora end def push_to(recipients) - puts "recipients are #{recipients.inspect}" unless recipients.empty? recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) diff --git a/spec/factories.rb b/spec/factories.rb index 4da77078c..88f34e1f6 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -20,12 +20,14 @@ Factory.define :person_with_private_key, :parent => :person do |p| p.serialized_key OpenSSL::PKey::RSA.generate(1024).export end +Factory.define :person_with_user, :parent => :person_with_private_key do |p| +end + Factory.define :user do |u| u.sequence(:email) {|n| "bob#{n}@aol.com"} u.password "bluepin7" u.password_confirmation "bluepin7" - - u.sequence(:person) {|p| Factory.create(:person_with_private_key, :email => "robert-#{p}@grimm.org")} + u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)} end Factory.define :status_message do |m| diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 773b8c6d9..9e9d61efa 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -12,6 +12,11 @@ describe 'making sure the spec runner works' do User.count.should == 0 end + it 'should factory create a user with a person saved' do + user = Factory.create(:user) + loaded_user = User.first(:id => user.id) + loaded_user.person.owner_id.should == user.id + end describe 'testing a before do block' do before do Factory.create(:user) diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 9ccaa1c5e..da11dbfae 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Retraction do before do @user = Factory.create(:user) - @user.person.save @post = @user.post(:status_message, :message => "Destroy!") @person = Factory.create(:person) @user.friends << @person