From da16e3ee1e2a4b5084cad9d06e852079a8182408 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Tue, 23 Nov 2010 00:08:30 -0800
Subject: [PATCH] PALINDROME invite form can now take comma seperated multiple
 emails, so you only have to click the box once

---
 app/controllers/invitations_controller.rb     |  16 +-
 app/models/invitation.rb                      |  36 +-
 app/models/user.rb                            |  30 +-
 .../requests/_manage_aspect_contacts.haml     |   2 -
 app/views/shared/_aspect_contacts.haml        |   1 -
 app/views/shared/_invitations.haml            |  15 +-
 config/locales/diaspora/en.yml                |   3 +-
 .../invitations_controller_spec.rb            |  48 +-
 spec/fixtures/users.yaml                      | 546 +++++++++---------
 spec/models/invitation_spec.rb                |  55 +-
 spec/models/user/invite_spec.rb               |   7 -
 11 files changed, 413 insertions(+), 346 deletions(-)

diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index 2059368b8a..041e530f5c 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -8,12 +8,22 @@ class InvitationsController < Devise::InvitationsController
 
 
   def create
+      if current_user.invites == 0
+        flash[:error] = I18n.t 'invitations.create.no_more'
+        redirect_to :back
+        return
+      end
     begin
       params[:user][:aspect_id] = params[:user].delete(:aspects)
       message = params[:user].delete(:invite_messages)
       params[:user][:invite_message] = message unless message == ""
-      self.resource = current_user.invite_user(params[resource_name])
-      flash[:notice] = I18n.t 'invitations.create.sent'
+
+      emails = params[:user][:email].split(/, */)
+      invited_users = emails.map { |e| current_user.invite_user(params[:user].merge({:email => e}))}
+      good_users, rejected_users = invited_users.partition {|u| u.persisted? }
+
+      flash[:notice] = I18n.t('invitations.create.sent') + good_users.map{|x| x.email}.join(', ') 
+      flash[:error] = I18n.t('invitations.create.REJECTED') + rejected_users.map{|x| x.email}.join(', ')
     rescue RuntimeError => e
       if  e.message == "You have no invites"
         flash[:error] = I18n.t 'invitations.create.no_more'
@@ -25,7 +35,7 @@ class InvitationsController < Devise::InvitationsController
         raise e
       end
     end
-    redirect_to after_sign_in_path_for(resource_name)
+    redirect_to :back 
   end
 
   def update
diff --git a/app/models/invitation.rb b/app/models/invitation.rb
index c7f3fb8b82..eab3ce575e 100644
--- a/app/models/invitation.rb
+++ b/app/models/invitation.rb
@@ -24,14 +24,7 @@ class Invitation
         raise "You already invited this person"
       end
     end
-
-    invited_user = create_invitee(opts)
-    if invited_user.persisted?
-
-      invited_user
-    else
-      false
-    end
+    create_invitee(opts)
   end
 
   def self.create_invitee(opts = {})
@@ -43,20 +36,23 @@ class Invitation
       invitee.errors.add(:email, :taken) unless invitee.invited?
     end
 
-    if opts[:from]
-      invitee.save(:validate => false)
-      Invitation.create!(:from => opts[:from],
-                         :to => invitee,
-                         :into => opts[:into],
-                         :message => opts[:message])
+    if invitee.errors.empty?
 
-      opts[:from].invites -= 1
-      opts[:from].save!
-      invitee.reload
-    end
+      if opts[:from]
+        invitee.save(:validate => false)
+        Invitation.create!(:from => opts[:from],
+                           :to => invitee,
+                           :into => opts[:into],
+                           :message => opts[:message])
+
+        opts[:from].invites -= 1 unless opts[:from].invites == 0
+        opts[:from].save!
+        invitee.reload
+      end
 
-    invitee.send(:generate_invitation_token)
-    invitee.invite! if invitee.errors.empty?
+      invitee.send(:generate_invitation_token)
+      invitee.invite! 
+    end
     invitee
   end
 
diff --git a/app/models/user.rb b/app/models/user.rb
index 44190e99b8..575934b6a6 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -19,7 +19,7 @@ class User
 
   key :username
   key :serialized_private_key, String
-  key :invites, Integer, :default => 0
+  key :invites, Integer, :default => 5
   key :invitation_token, String
   key :invitation_sent_at, DateTime
   key :pending_request_ids, Array, :typecast => 'ObjectId'
@@ -321,23 +321,19 @@ class User
 
   ###Invitations############
   def invite_user(opts = {})
-    if self.invites > 0
-      aspect_id = opts.delete(:aspect_id)
-      if aspect_id == nil
-        raise "Must invite into aspect"
-      end
-      aspect_object = self.aspects.find_by_id(aspect_id)
-      if !(aspect_object)
-        raise "Must invite to your aspect"
-      else
-        Invitation.invite(:email => opts[:email],
-                          :from => self,
-                          :into => aspect_object,
-                          :message => opts[:invite_message])
-
-      end
+    aspect_id = opts.delete(:aspect_id)
+    if aspect_id == nil
+      raise "Must invite into aspect"
+    end
+    aspect_object = self.aspects.find_by_id(aspect_id)
+    if !(aspect_object)
+      raise "Must invite to your aspect"
     else
-      raise "You have no invites"
+      Invitation.invite(:email => opts[:email],
+                        :from => self,
+                        :into => aspect_object,
+                        :message => opts[:invite_message])
+
     end
   end
 
diff --git a/app/views/requests/_manage_aspect_contacts.haml b/app/views/requests/_manage_aspect_contacts.haml
index bed3aef129..0e1901f292 100644
--- a/app/views/requests/_manage_aspect_contacts.haml
+++ b/app/views/requests/_manage_aspect_contacts.haml
@@ -11,7 +11,5 @@
     %h3= t('.existing')
     = render 'shared/contact_list', :aspect => aspect, :contacts => @contacts, :manage => defined?(manage)
 
-  
-  
   .span-7.last
     = render 'shared/add_contact', :aspect => aspect
diff --git a/app/views/shared/_aspect_contacts.haml b/app/views/shared/_aspect_contacts.haml
index 363c9f713d..b1274f35b6 100644
--- a/app/views/shared/_aspect_contacts.haml
+++ b/app/views/shared/_aspect_contacts.haml
@@ -113,6 +113,5 @@
       %br
 
       %h3= t('.invites')
-      %p= t('.invite_people')
       = render "shared/invitations", :invites => @invites
 
diff --git a/app/views/shared/_invitations.haml b/app/views/shared/_invitations.haml
index 45efb736d3..f3ebf1dcec 100644
--- a/app/views/shared/_invitations.haml
+++ b/app/views/shared/_invitations.haml
@@ -1,6 +1,9 @@
-= link_to t('.invite_someone'), "#invite_user_pane", :class => "invite_user_button", :title => t('.invite_someone')
-= t('.invitations_left', :count => invites) 
-%br
-.yo{ :style => "display:none;"}
-  #invite_user_pane
-    = render "invitations/new"
+-if invites > 0
+  = link_to t('.invite_someone'), "#invite_user_pane", :class => "invite_user_button", :title => t('.invite_someone')
+  = t('.invitations_left', :count => invites) 
+  %br
+  .yo{ :style => "display:none;"}
+    #invite_user_pane
+      = render "invitations/new"
+- else
+  You don't have any right now, but more invites are coming soon!
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 055a7ee832..a6cbbe793b 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -260,7 +260,8 @@ en:
       closed: "Signups are closed on this Diaspora pod."
   invitations:
       create:
-          sent: "Your invitation has been sent."
+          sent: "Invitations have been sent to: "
+          REJECTED: "The following email addresses had problems: "
           no_more: "You have no more invitations."
           already_sent: "You already invited this person."
           already_contacts: "You are already connected with this person" 
diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb
index cd382e0cbe..bc1977e2cf 100644
--- a/spec/controllers/invitations_controller_spec.rb
+++ b/spec/controllers/invitations_controller_spec.rb
@@ -14,33 +14,63 @@ describe InvitationsController do
   
   before do
     request.env["devise.mapping"] = Devise.mappings[:user]
-    user.invites = 3
+    user.invites = 5
 
     sign_in :user, user
-
+    @invite = {:invite_messages=>"test", :aspects=> aspect.id.to_s, :email=>"abc@example.com"}
     @controller.stub!(:current_user).and_return(user)
+    request.env["HTTP_REFERER"]= 'http://test.host/cats/foo'
   end
 
   describe "#create" do
     it 'invites the requested user' do
-      user.should_receive(:invite_user).once
-      post :create, :user=>{:invite_messages=>"test", :aspects=> aspect.id.to_s, :email=>"abc@example.com"}
+      user.should_receive(:invite_user).and_return(make_user)
+      post :create, :user => @invite
     end
 
     it 'creates an invitation' do
       lambda{
-        post :create, :user=>{:invite_messages=>"test", :aspects=> aspect.id.to_s, :email=>"abc@example.com"}
+        post :create, :user => @invite
       }.should change(Invitation, :count).by(1)
     end
 
-    it 'creates an invited user with zero invites' do
+    it 'creates an invited user with five invites' do
       lambda{
-        post :create, :user=>{:invite_messages=>"test", :aspects=> aspect.id.to_s, :email=>"abc@example.com"}
+        post :create, :user => @invite
       }.should change(User, :count).by(1)
-      User.find_by_email("abc@example.com").invites.should == 0
+      User.find_by_email("abc@example.com").invites.should == 5
+    end
+
+    it 'can handle a comma seperated list of emails' do
+      lambda {
+        post :create, :user => @invite.merge(:email => "foofoofoofoo@example.com, mbs@gmail.com")
+      }.should change(User, :count).by(2)
+    end
+
+    it 'displays a message that tells you how many invites were sent, and which REJECTED' do
+      post :create, :user => @invite.merge(:email => "mbs@gmail.com, foo@bar.com, foo.com, lala@foo, cool@bar.com")
+      flash[:notice].should_not be_empty
+      flash[:notice].should =~ /mbs@gmail\.com/
+      flash[:notice].should =~ /foo@bar\.com/
+      flash[:notice].should =~ /cool@bar\.com/
+
+      flash[:error].should_not be_empty
+      flash[:error].should =~ /foo\.com/
+      flash[:error].should =~ /lala@foo/
+    end
+
+    it "doesn't invite anyone if you have 0 invites" do
+      user.invites = 0
+      user.save!
+      lambda {
+        post :create, :user => @invite.merge(:email => "mbs@gmail.com, foo@bar.com, foo.com, lala@foo, cool@bar.com")
+      }.should_not change(User, :count)
+    end
 
+    it 'returns to the previous page on success' do
+      post :create, :user => @invite
+      response.should redirect_to("http://test.host/cats/foo")
     end
-    
   end
 end
 
diff --git a/spec/fixtures/users.yaml b/spec/fixtures/users.yaml
index a2cf32fbb1..2fce20233e 100644
--- a/spec/fixtures/users.yaml
+++ b/spec/fixtures/users.yaml
@@ -1,7 +1,7 @@
 --- 
 :users: 
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:34 Z
+    created_at: 2010-11-23 08:02:59 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -9,104 +9,104 @@
         data: 
         - 76
         - 235
-        - 40
-        - 238
+        - 117
+        - 51
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 95
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm87ec9108
+      last_name: Grimm87ed1f78
       bio: 
-      first_name: Robert879fa975
-    updated_at: 2010-11-23 02:37:34 Z
+      first_name: Robert87777f99
+    updated_at: 2010-11-23 08:02:59 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 238
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 96
-    url: http://google-870677ec.com/
+    url: http://google-87b7ddac.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id001 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 238
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 94
-    diaspora_handle: bob860dfd9d@example.org
+    diaspora_handle: bob867d9fc4@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$JbOCB9ESEGiUMvqV3umDWeJrZ59YKmXmR90VYSCdD9B8SsBMrWn4m
+    encrypted_password: $2a$10$Y1Q6aU.9mBFFZxrcZYIlD.L.5CdZ8wvSGLJKt69CoBRoVPsKB4uVS
     serialized_private_key: &id002 |
       -----BEGIN RSA PRIVATE KEY-----
-      MIICWwIBAAKBgQCnTkpjwI58KypOFTTgteoBhDTpG8iCtTEQoYH3zlbghGtnlJk2
-      EZU6EOEuRP9Rzpj01KzdG9iB3ezhiofQCgrb5p9AODw1IwXqLgfftjWbpAimGmjC
-      RrxWLVObepomcSCXnQO4EPvKEow1nHCjk35cGGwja7q1RhkSNwjYv2xCMwIDAQAB
-      AoGAf/i5m/2Av2eBD4LXFH7xREGs+xV+VMRliFQRhsv01f1T7kHSw3HFlEmvBGZQ
-      aXG+u58lrmcLP6LR+16sLaxQytCeYVOo6zE3cpJx8ZOEEvCpCcpPgJY/4NgIqplA
-      qaDvceUu6jtCnSO3w6jVvqfDlj4K1y0AJwHyqTVXL/SxJrECQQDWIaY6mQrylH1T
-      BR9+BEChOWSxf25kq/F2lpIdGv8+yqa3dCmaryOd8bhsw3ayezg5kD7Go3np7Txg
-      Cn7/oOX5AkEAyATI2H6CPtnsESp992D2z7NayKmzx8BVT+UDwiKzJBenaAP8IAp0
-      GbpfxJL27tceh9vSDo4iT4C9lmaCAxOEiwJAQ/8ddSAiLNPgVBudW3voNgouonqv
-      yIIdRCYeMeXfxcW+WSUnDPqumboncUpEh/q+6PCYLqW80f7GnEzY9T3XqQJAeJWZ
-      2Br8vpN2pCqv4nGMmk8QjiTxA53KUO5KQ8HTqhCwlh7A4zgqIlCf58yKHheGinVV
-      v/ykZrXAlmmaO+yKXQJAIQFTfBx35mU53jh6HvLw5TZdcsGYovgw78VPRXJU4qnT
-      95bKHZA+KR2pNFBs+chzeQ8OXzidQ+OJQgtCF46s4A==
+      MIICWwIBAAKBgQDPhufcrB3XjkirWnvSsqhkzGpI9di+ekFkG5kQnkhXsuupMsOE
+      c5Bhu3hTBGVwpjrSZJEFClj908crNmMHmWkbm8ZA3gwkq+uq2C0Ea4AyK8xunsa1
+      W6XgOhBFV/r9iHEpgI6o08s5uyEMlyuMMCl+5M70R8ln9tvbBspOWuCwEwIDAQAB
+      AoGAMRNL/WlOXU0ubiclpPvOypd0gvBwYwryL8Q+/CkSHnsXM5nnlojlmdcFa0xc
+      2LjWrC5QBQsfZFcSgGuKG5/xtMJrg84A1VziA1aKTH3SK4M9I5v90T5jKybBcJhm
+      woQWciOauXSxmEMIF8zsQH33Du96silGtRS1Y21q6bOyL7ECQQD2ta/MIWfPn3wM
+      EAZrxVXcG4DJ9cQcDJduatKj5JZe6At8Iqpph9W2GU+OoALAQrRA0XRj9jHPE/jJ
+      0FYVA1tHAkEA11d+DIV9w/XBb/KF8TdJgbsOpqP+B7opzvkj6fsRDhlzN7abFXlj
+      vrj/prkamJOwmVNVmokjRKWfZFmw799S1QJAQl/fTCwwoctmtFgbYiNVVkKQA8X7
+      XRCGLU7QHQgC7MXBUUSCVKIW/UcSAG1MUC2iEU5I4hv6ipv081b50e11QQJAAhLG
+      lOpIHrXkCebk4UCuBYC+kF4t2Pcy5dpCPUN8k40tLdElRxynGDQByiIoHmX1olRK
+      E7XUUBnkIfw3FugojQJAEGOTQi0whDfu563kMupERU6ZkMz//rQKcqAHHujaZLcE
+      G5N7S5ohbjNUrjQKPejax0+TMKpIlWHx1LBGSKFaKg==
       -----END RSA PRIVATE KEY-----
 
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id001
     last_sign_in_at: 
-    username: bob860dfd9d
+    username: bob867d9fc4
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$JbOCB9ESEGiUMvqV3umDWe
+    password_salt: $2a$10$Y1Q6aU.9mBFFZxrcZYIlD.
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob8710baa6@pivotallabs.com
+    email: bob87947110@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:34 Z
+    created_at: 2010-11-23 08:02:59 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -114,88 +114,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 238
+        - 117
+        - 51
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 98
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm886a1c5a
+      last_name: Grimm8897d77e
       bio: 
-      first_name: Robert88567c31
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert88082241
+    updated_at: 2010-11-23 08:02:59 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 238
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 99
-    url: http://google-88117a1b.com/
+    url: http://google-88ca5b88.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id003 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 238
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 97
-    diaspora_handle: bob8720e990@example.org
+    diaspora_handle: bob878a464a@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$DxCn2UtXrJNsxx5DgoDjBelzzHhpkkZJ7jkyNjf4uPUXUKVTEY.kK
+    encrypted_password: $2a$10$pVZjeQNn/vvXCB2ohJn2uua6JOZ/0gbs/N.HuKSP6g7QTopwmlIzu
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id003
     last_sign_in_at: 
-    username: bob8720e990
+    username: bob878a464a
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$DxCn2UtXrJNsxx5DgoDjBe
+    password_salt: $2a$10$pVZjeQNn/vvXCB2ohJn2uu
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob88fae3cf@pivotallabs.com
+    email: bob884ff707@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:02:59 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -203,88 +203,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 51
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 101
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm89470cdc
+      last_name: Grimm89a984dd
       bio: 
-      first_name: Robert895c8ca2
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert89fcc077
+    updated_at: 2010-11-23 08:02:59 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 102
-    url: http://google-8929757e.com/
+    url: http://google-89cb88a6.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id004 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 100
-    diaspora_handle: bob888b9d17@example.org
+    diaspora_handle: bob882fbc0c@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$YM5IlkhENtaCwWyO.lo32u6SKVG/aHJWbkUUllDNwVgIdWVb6IsT.
+    encrypted_password: $2a$10$FbNAlEiJR9bZRnPJvLISmOOZlW4yfpQ5ooJBPmgoVGU3w7vF.5K0.
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id004
     last_sign_in_at: 
-    username: bob888b9d17
+    username: bob882fbc0c
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$YM5IlkhENtaCwWyO.lo32u
+    password_salt: $2a$10$FbNAlEiJR9bZRnPJvLISmO
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob897d2a9a@pivotallabs.com
+    email: bob89903478@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:02:59 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -292,88 +292,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 51
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 104
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm90e0018e
+      last_name: Grimm9014bcfd
       bio: 
-      first_name: Robert902be984
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert90559501
+    updated_at: 2010-11-23 08:02:59 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 105
-    url: http://google-903e1126.com/
+    url: http://google-90bee2e2.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id005 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 103
-    diaspora_handle: bob8984fb60@example.org
+    diaspora_handle: bob89ca7f5b@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$7HnsQqNfP7C/IhUbx0UAteqJ1uCDMAHRJgfI3iZVu0pSwfh/6Xbpu
+    encrypted_password: $2a$10$wg0QeGPKwpw3y4OynIvbIucSDmgvZ7amgin7vhlDMP9qcdIxrxgk.
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id005
     last_sign_in_at: 
-    username: bob8984fb60
+    username: bob89ca7f5b
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$7HnsQqNfP7C/IhUbx0UAte
+    password_salt: $2a$10$wg0QeGPKwpw3y4OynIvbIu
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob9009cefd@pivotallabs.com
+    email: bob90187d25@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -381,88 +381,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 107
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm91885043
+      last_name: Grimm9100c957
       bio: 
-      first_name: Robert910cec13
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert91d04f7a
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 108
-    url: http://google-91a2e449.com/
+    url: http://google-91ded544.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id006 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 51
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 106
-    diaspora_handle: bob90009b55@example.org
+    diaspora_handle: bob90302cbd@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$qBM5ct0gRQc.Q1wiwvFjx..zNlBnXbUXhoZhHoytjvaFeHXNg2SQ.
+    encrypted_password: $2a$10$N8YWCf220R00eCxv71qruOvSfJnjU3MZ9ItvTYSwwy9teNCs1j.3e
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id006
     last_sign_in_at: 
-    username: bob90009b55
+    username: bob90302cbd
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$qBM5ct0gRQc.Q1wiwvFjx.
+    password_salt: $2a$10$N8YWCf220R00eCxv71qruO
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob91daad1e@pivotallabs.com
+    email: bob911a6739@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -470,88 +470,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 110
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm92104c8f
+      last_name: Grimm923a04b0
       bio: 
-      first_name: Robert923c26f1
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert928d26da
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 111
-    url: http://google-9280bb05.com/
+    url: http://google-928d12c8.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id007 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 109
-    diaspora_handle: bob91ecf16e@example.org
+    diaspora_handle: bob910dcc30@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$4FrHuInLjjhdfX/oF76kGuGLBjwIQjdicVlBTQsRDKXp1F.86BAs2
+    encrypted_password: $2a$10$OVzwf.dHCZlTHWLjAEY91OFb8a/cRD3YkQEWwV4M.rPP5LR2XgL46
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id007
     last_sign_in_at: 
-    username: bob91ecf16e
+    username: bob910dcc30
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$4FrHuInLjjhdfX/oF76kGu
+    password_salt: $2a$10$OVzwf.dHCZlTHWLjAEY91O
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob92be1a2e@pivotallabs.com
+    email: bob9241b6ce@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -559,88 +559,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 113
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm93d8e1f0
+      last_name: Grimm93572cb5
       bio: 
-      first_name: Robert93b0ad94
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert9334ab75
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 114
-    url: http://google-930fc7b9.com/
+    url: http://google-93888f53.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id008 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 112
-    diaspora_handle: bob924e8f78@example.org
+    diaspora_handle: bob92a84451@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$F.S6sOeVJn7ZH8nFxn3VDOGRe2Hx3jJG9qkWqdS5YATO4bN89ep.K
+    encrypted_password: $2a$10$ScX4hDPEXy8dI2MvilARFO2nDo3PQaFGuYrTLE4lCJ4YWHJQAXcjS
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id008
     last_sign_in_at: 
-    username: bob924e8f78
+    username: bob92a84451
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$F.S6sOeVJn7ZH8nFxn3VDO
+    password_salt: $2a$10$ScX4hDPEXy8dI2MvilARFO
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob93ee4613@pivotallabs.com
+    email: bob93239865@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -648,88 +648,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 116
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm944cfda1
+      last_name: Grimm941c32cf
       bio: 
-      first_name: Robert944eddee
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert94f06768
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 117
-    url: http://google-94dcee0c.com/
+    url: http://google-947a4701.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id009 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 115
-    diaspora_handle: bob93cd51e3@example.org
+    diaspora_handle: bob93876ba3@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$70u/HHIfBqtu08.UPjl0c.RklfkfR2ZlV4DI.e7p5fXBKVa.RCWKW
+    encrypted_password: $2a$10$vxMxLozMdv/ufLb5x1OEyeoOY6mtM7soOhBseJJ2P/jfeg1DYFpE.
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id009
     last_sign_in_at: 
-    username: bob93cd51e3
+    username: bob93876ba3
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$70u/HHIfBqtu08.UPjl0c.
+    password_salt: $2a$10$vxMxLozMdv/ufLb5x1OEye
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob94d8ef2a@pivotallabs.com
+    email: bob945371dc@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:35 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -737,88 +737,88 @@
         data: 
         - 76
         - 235
-        - 40
-        - 239
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 119
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm95fa68e4
+      last_name: Grimm9587d9a5
       bio: 
-      first_name: Robert95cada39
-    updated_at: 2010-11-23 02:37:35 Z
+      first_name: Robert95f0439f
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 120
-    url: http://google-95ddfcd0.com/
+    url: http://google-951b0b44.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id010 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 118
-    diaspora_handle: bob9477d9ee@example.org
+    diaspora_handle: bob94f0ec6b@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$7LwkEiLnIaMq9AcOGaXqSOo5Nv/mWfvdZCuSNB0E.SN9k1amFypR6
+    encrypted_password: $2a$10$BzTWhaVgvvB/IpWHpEZ3d.bmv0t5VXCtIOu1eqMUWYWFBMh4C39IK
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id010
     last_sign_in_at: 
-    username: bob9477d9ee
+    username: bob94f0ec6b
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$7LwkEiLnIaMq9AcOGaXqSO
+    password_salt: $2a$10$BzTWhaVgvvB/IpWHpEZ3d.
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob95ea4426@pivotallabs.com
+    email: bob956abea5@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
     getting_started: true
 - :person: !map:ActiveSupport::HashWithIndifferentAccess 
-    created_at: 2010-11-23 02:37:36 Z
+    created_at: 2010-11-23 08:03:00 Z
     profile: !map:ActiveSupport::HashWithIndifferentAccess 
       searchable: true
       image_url: 
@@ -826,82 +826,82 @@
         data: 
         - 76
         - 235
-        - 40
-        - 240
+        - 117
+        - 52
         - 55
         - 219
         - 91
-        - 17
-        - 107
+        - 40
+        - 113
         - 0
         - 1
         - 122
       gender: 
       diaspora_handle: 
       birthday: 
-      last_name: Grimm96217166
+      last_name: Grimm963be886
       bio: 
-      first_name: Robert968348a2
-    updated_at: 2010-11-23 02:37:36 Z
+      first_name: Robert9665b010
+    updated_at: 2010-11-23 08:03:00 Z
     _id: !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 240
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 123
-    url: http://google-9613c8cc.com/
+    url: http://google-96685714.com/
     serialized_public_key: |
       -----BEGIN RSA PUBLIC KEY-----
-      MIGJAoGBAKdOSmPAjnwrKk4VNOC16gGENOkbyIK1MRChgffOVuCEa2eUmTYRlToQ
-      4S5E/1HOmPTUrN0b2IHd7OGKh9AKCtvmn0A4PDUjBeouB9+2NZukCKYaaMJGvFYt
-      U5t6miZxIJedA7gQ+8oSjDWccKOTflwYbCNrurVGGRI3CNi/bEIzAgMBAAE=
+      MIGJAoGBAM+G59ysHdeOSKtae9KyqGTMakj12L56QWQbmRCeSFey66kyw4RzkGG7
+      eFMEZXCmOtJkkQUKWP3Txys2YweZaRubxkDeDCSr66rYLQRrgDIrzG6exrVbpeA6
+      EEVX+v2IcSmAjqjTyzm7IQyXK4wwKX7kzvRHyWf229sGyk5a4LATAgMBAAE=
       -----END RSA PUBLIC KEY-----
 
     owner_id: &id011 !ruby/object:BSON::ObjectId 
       data: 
       - 76
       - 235
-      - 40
-      - 239
+      - 117
+      - 52
       - 55
       - 219
       - 91
-      - 17
-      - 107
+      - 40
+      - 113
       - 0
       - 1
       - 121
-    diaspora_handle: bob95b79804@example.org
+    diaspora_handle: bob95aa81c1@example.org
   :user: !map:ActiveSupport::HashWithIndifferentAccess 
-    encrypted_password: $2a$10$SvY1DuVtUNv4gOan5Du.PexJ43O0SyGeCso9iBVKNSyCB606clCsm
+    encrypted_password: $2a$10$4oW4dUuMs6ELZFxTmD9ok./M84AdkUl0ExNQgUwYFZxq3JBE/TsFG
     serialized_private_key: *id002
     pending_request_ids: []
 
     last_sign_in_ip: 
-    invites: 0
+    invites: 5
     _id: *id011
     last_sign_in_at: 
-    username: bob95b79804
+    username: bob95aa81c1
     language: en
     sign_in_count: 0
     visible_person_ids: []
 
-    password_salt: $2a$10$SvY1DuVtUNv4gOan5Du.Pe
+    password_salt: $2a$10$4oW4dUuMs6ELZFxTmD9ok.
     remember_token: 
     reset_password_token: 
     current_sign_in_ip: 
     remember_created_at: 
     current_sign_in_at: 
     invitation_sent_at: 
-    email: bob962face3@pivotallabs.com
+    email: bob962bf01f@pivotallabs.com
     invitation_token: 
     visible_post_ids: []
 
diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb
index d83e4e1738..20329da34f 100644
--- a/spec/models/invitation_spec.rb
+++ b/spec/models/invitation_spec.rb
@@ -49,25 +49,30 @@ describe Invitation do
         Invitation.invite(:email => @email, :from => user, :into => aspect)
       }.should change(Invitation, :count).by(1)
     end
+
     it 'associates the invitation with the inviter' do
       lambda {
         Invitation.invite(:email => @email, :from => user, :into => aspect)
       }.should change{user.reload.invitations_from_me.count}.by(1)
     end
+    
     it 'associates the invitation with the invitee' do
       new_user = Invitation.invite(:email => @email, :from => user, :into => aspect)
       new_user.invitations_to_me.count.should == 1
     end
+    
     it 'creates a user' do
       lambda {
         Invitation.invite(:from => user, :email => @email, :into => aspect)
       }.should change(User, :count).by(1)
     end
+    
     it 'returns the new user' do
       new_user = Invitation.invite(:from => user, :email => @email, :into => aspect)
       new_user.is_a?(User).should be_true
       new_user.email.should == @email
     end
+    
     it 'adds the inviter to the invited_user' do
       new_user = Invitation.invite(:from => user, :email => @email, :into => aspect)
       new_user.invitations_to_me.first.from.should == user
@@ -87,27 +92,63 @@ describe Invitation do
       }
       Invitation.invite(:from => user, :email => user2.email, :into => aspect)
     end
+
+    it 'decrements the invite count of the from user' do
+      message = "How've you been?"
+      lambda{
+        new_user = Invitation.invite(:from => user, :email => @email, :into => aspect, :message => message)
+      }.should change(user, :invites).by(-1) 
+    end
+    
+    it "doesn't decrement counter past zero" do
+      user.invites = 0
+      user.save!
+      message = "How've you been?"
+      lambda {
+        new_user = Invitation.invite(:from => user, :email => @email, :into => aspect, :message => message)
+      }.should_not change(user, :invites)
+    end
+
+    context 'invalid email' do
+    
+      it 'return a user with errors' do
+        new_user = Invitation.invite(:email => "fkjlsdf", :from => user, :into => aspect)
+        new_user.should have(1).errors_on(:email)
+        new_user.should_not be_persisted
+      end
+    end
   end
 
   describe '.create_invitee' do
     context 'with an inviter' do
+      before do
+        @message = "whatever"
+        @valid_params = {:from => user, :email => @email, :into => aspect, :message => @message}
+      end
+
       it 'sends mail' do
-        message = "How've you been?"
         lambda {
-          Invitation.create_invitee(:from => user, :email => @email, :into => aspect, :message => message)
+          Invitation.create_invitee(@valid_params)
         }.should change{Devise.mailer.deliveries.size}.by(1)
       end
+
       it 'mails the optional message' do
-        message = "How've you been?"
-        new_user = Invitation.create_invitee(:from => user, :email => @email, :into => aspect, :message => message)
-        Devise.mailer.deliveries.first.to_s.include?(message).should be_true
+        new_user = Invitation.create_invitee(@valid_params)
+        Devise.mailer.deliveries.first.to_s.include?(@message).should be_true
       end
+
       it 'has no translation missing' do
-        message = "How've you been?"
-        new_user = Invitation.create_invitee(:from => user, :email => @email, :into => aspect, :message => message)
+        new_user = Invitation.create_invitee(@valid_params)
         Devise.mailer.deliveries.first.body.raw_source.match(/(translation_missing.+)/).should be_nil
       end
+
+      it "doesn't create an invitation if the email is invalid" do
+         new_user = Invitation.create_invitee(@valid_params.merge(:email => 'fdfdfdfdf'))
+         new_user.should_not be_persisted
+         new_user.should have(1).error_on(:email)
+      end
     end
+
     context 'with no inviter' do
       it 'sends an email that includes the right things' do
         Invitation.create_invitee(:email => @email)
diff --git a/spec/models/user/invite_spec.rb b/spec/models/user/invite_spec.rb
index 4b670997b1..c6e560d0e3 100644
--- a/spec/models/user/invite_spec.rb
+++ b/spec/models/user/invite_spec.rb
@@ -49,13 +49,6 @@ describe User do
 
   context "limit on invites" do
 
-    it 'does not invite users after 3 invites' do
-      inviter_with_3_invites.invite_user(:email => "email1@example.com", :aspect_id => aspect2.id)
-      inviter_with_3_invites.invite_user(:email => "email2@example.com", :aspect_id => aspect2.id)
-      inviter_with_3_invites.invite_user(:email => "email3@example.com", :aspect_id => aspect2.id)
-      proc{inviter_with_3_invites.invite_user(:email => "email4@example.com", :aspect_id => aspect2.id)}.should raise_error /You have no invites/
-    end
-
     it 'does not invite people I already invited' do
       inviter_with_3_invites.invite_user(:email => "email1@example.com", :aspect_id => aspect2.id)
       proc{inviter_with_3_invites.invite_user(:email => "email1@example.com", :aspect_id => aspect2.id)}.should raise_error /You already invited this person/
-- 
GitLab