diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 7f27c56269a72282543bc11bef0b705cf28cf10f..877ffc13f6c3bb93951916c78c0bf92e7e1d277b 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -2,14 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => citie - require File.join(File.dirname(__FILE__), "..", "..", "config", "environment") def create @@ -32,7 +24,8 @@ def create :person => Person.new( :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'], :image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg") - )).save + )) + user.save user.person.save! user.aspect(:name => "Presidents") diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 7eed484c0d44d78c7b8322ee9003e78e61a66849..0acf31f385bcdad42e1dbca412ebf61fa369d6d2 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -24,7 +24,8 @@ user = User.build( :email => "tom@tom.joindiaspora.com", :password_confirmation => "evankorth", :person => Person.new( :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) - ).save + ) +user.save user.person.save! user.seed_aspects @@ -33,8 +34,10 @@ user2 = User.build( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :password_confirmation => "evankorth", :person => Person.new( - :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))).save + :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))) + +user2.save user2.person.save! user2.seed_aspects diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 2bd21e169a291fdc131bafd3ae43176e40fec8f9..d04a334aae32a3250073078fabbadeb89512402a 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -25,7 +25,8 @@ user = User.build( :email => "tom@tom.joindiaspora.com", :person => { :profile => { :first_name => "Alexander", :last_name => "Hamiltom", :image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}} - ).save! + ) +user.save! user.seed_aspects user.person.save! @@ -35,6 +36,7 @@ user2 = User.build( :email => "korth@tom.joindiaspora.com", :username => "korth", :person => {:profile => { :first_name => "Evan", :last_name => "Korth", :image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}}) +user2.save! user2.seed_aspects user2.person.save! diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index bae837b09dc49d22baa26c2e78fd94a045c2564a..2fde487b3c619c516aa2fa7ec6928a2a7086ca4c 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -7,6 +7,7 @@ require 'spec_helper' describe User do let(:user) {Factory.create :user} let(:aspect) {user.aspect(:name => 'heroes')} + let(:aspect1) {user.aspect(:name => 'other')} let(:friend) { Factory.create(:person) } let(:person_one) {Factory.create :person} @@ -174,6 +175,14 @@ describe User do aspect.reload.people.count.should == 0 end + it 'should remove the friend from all aspects they are in' do + user.add_person_to_aspect(user2.person.id, aspect1.id) + lambda {user.unfriended_by user2.person}.should change{ + user.friends.count}.by(-1) + aspect.reload.people.count.should == 0 + aspect1.reload.people.count.should == 0 + end + context 'with a post' do before do @message = user.post(:status_message, :message => "hi", :to => aspect.id)