Skip to content
Snippets Groups Projects
Commit d98ac701 authored by Raphael's avatar Raphael
Browse files

Clean up some repetition in specs

parent 197bd8eb
No related branches found
No related tags found
No related merge requests found
......@@ -77,64 +77,38 @@ describe Person do
person_two.owns?(person_message).should be false
end
it 'should delete all of user posts except comments upon user deletion' do
it "deletes all of a person's posts upon person deletion" do
person = Factory.create(:person)
Factory.create(:status_message, :person => person)
Factory.create(:status_message, :person => person)
Factory.create(:status_message, :person => person)
Factory.create(:status_message, :person => person)
status = Factory.create(:status_message, :person => person)
Factory.create(:status_message, :person => @person)
lambda {person.destroy}.should change(Post, :count).by(-1)
end
it "does not delete a person's comments on person deletion" do
person = Factory.create(:person)
status_message = Factory.create(:status_message, :person => @person)
Factory.create(:comment, :person_id => person.id, :text => "yes i do", :post => status_message)
Factory.create(:comment, :person_id => person.id, :text => "i love you", :post => status_message)
Factory.create(:comment, :person_id => person.id, :text => "hello", :post => status_message)
Factory.create(:comment, :person_id => @person.id, :text => "you are creepy", :post => status_message)
person.destroy
Post.count.should == 1
Comment.all.count.should == 4
status_message.comments.count.should == 4
lambda {person.destroy}.should_not change(Comment, :count)
end
describe "unfriending" do
it 'should not delete an orphaned friend' do
request = @user.send_friend_request_to @person, @aspect
@user.activate_friend(@person, @aspect)
@user.reload
Person.all.count.should == 3
@user.friends.count.should == 1
@user.unfriend(@person)
@user.reload
@user.friends.count.should == 0
Person.all.count.should == 3
lambda {@user.unfriend(@person)}.should_not change(Person, :count)
end
it 'should not delete an un-orphaned friend' do
request = @user.send_friend_request_to @person, @aspect
request2 = @user2.send_friend_request_to @person, @aspect2
@user.activate_friend(@person, @aspect)
@user2.activate_friend(@person, @aspect2)
@user.reload
@user2.reload
Person.all.count.should == 3
@user.friends.count.should == 1
@user2.friends.count.should == 1
@user.unfriend(@person)
@user.reload
@user2.reload
@user.friends.count.should == 0
@user2.friends.count.should == 1
Person.all.count.should == 3
lambda {@user.unfriend(@person)}.should_not change(Person, :count)
end
end
......
......@@ -6,8 +6,7 @@ require 'spec_helper'
describe Post do
before do
@user = Factory.create(:user, :email => "bob@aol.com")
@user.person.save
@user = Factory.create(:user)
end
describe 'xml' do
......
......@@ -6,7 +6,7 @@ require 'spec_helper'
describe StatusMessage do
before do
@user = Factory.create(:user, :email => "bob@aol.com")
@user = Factory.create(:user)
@aspect = @user.aspect(:name => "losers")
end
......
......@@ -22,16 +22,13 @@ describe User do
it 'should be able to parse and store a status message from xml' do
status_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
person = user2.person
xml = status_message.to_diaspora_xml
user2.destroy
status_message.destroy
StatusMessage.all.size.should == 0
user.receive xml , user2.person
Post.all(:person_id => person.id).first.message.should == 'store this!'
StatusMessage.all.size.should == 1
user
lambda {user.receive xml , user2.person}.should change (Post,:count).by(1)
end
it 'should not create new aspects on message receive' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment