Refactor user_spec a little
This commit is contained in:
parent
fe1a6bce20
commit
41cfd36b19
1 changed files with 8 additions and 20 deletions
|
|
@ -9,8 +9,6 @@ describe User do
|
||||||
let(:aspect) { user.aspect(:name => 'heroes') }
|
let(:aspect) { user.aspect(:name => 'heroes') }
|
||||||
let(:user2) { Factory(:user) }
|
let(:user2) { Factory(:user) }
|
||||||
let(:aspect2) { user2.aspect(:name => 'stuff') }
|
let(:aspect2) { user2.aspect(:name => 'stuff') }
|
||||||
let(:user3) { Factory(:user) }
|
|
||||||
let(:aspect3) { user3.aspect(:name => 'stuff') }
|
|
||||||
|
|
||||||
describe "validation" do
|
describe "validation" do
|
||||||
describe "of associated person" do
|
describe "of associated person" do
|
||||||
|
|
@ -168,12 +166,7 @@ describe User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'account removal' do
|
describe 'account removal' do
|
||||||
before do
|
|
||||||
friend_users(user, aspect, user2, aspect2)
|
|
||||||
friend_users(user, aspect, user3, aspect3)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should unfriend everyone' do
|
it 'should unfriend everyone' do
|
||||||
user.should_receive(:unfriend_everyone)
|
user.should_receive(:unfriend_everyone)
|
||||||
user.destroy
|
user.destroy
|
||||||
|
|
@ -185,11 +178,8 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove all aspects' do
|
it 'should remove all aspects' do
|
||||||
aspects = user.aspects
|
aspect
|
||||||
aspects.count.should > 0
|
lambda {user.destroy}.should change{user.aspects.reload.count}.by(-1)
|
||||||
user.destroy
|
|
||||||
aspects.reload
|
|
||||||
aspects.count.should == 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#remove_person' do
|
describe '#remove_person' do
|
||||||
|
|
@ -209,20 +199,18 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#unfriend_everyone' do
|
describe '#unfriend_everyone' do
|
||||||
before do
|
|
||||||
user3.delete
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should send retractions to remote poeple' do
|
it 'should send retractions to remote poeple' do
|
||||||
|
user2.delete
|
||||||
|
user.activate_friend(user2.person, aspect)
|
||||||
|
|
||||||
user.should_receive(:unfriend).once
|
user.should_receive(:unfriend).once
|
||||||
user.destroy
|
user.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unfriend local people' do
|
it 'should unfriend local people' do
|
||||||
user2.friends.count.should be 1
|
friend_users(user, aspect, user2, aspect2)
|
||||||
user.destroy
|
lambda {user.destroy}.should change{user2.reload.friends.count}.by(-1)
|
||||||
user2.reload
|
|
||||||
user2.friends.count.should be 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue