make user/receive spec less repetitive
This commit is contained in:
parent
74ec629b01
commit
197bd8eb49
1 changed files with 19 additions and 63 deletions
|
|
@ -47,96 +47,52 @@ describe User do
|
|||
end
|
||||
|
||||
describe 'post refs' do
|
||||
it "should add a received post to the aspect and visible_posts array" do
|
||||
status_message = user.post :status_message, :message => "hi", :to =>aspect.id
|
||||
before do
|
||||
@status_message = user2.post :status_message, :message => "hi", :to =>aspect2.id
|
||||
user.receive @status_message.to_diaspora_xml, user2.person
|
||||
user.reload
|
||||
salmon = user.salmon(status_message).xml_for user2.person
|
||||
user2.receive_salmon salmon
|
||||
user2.reload
|
||||
user2.raw_visible_posts.include?(status_message).should be true
|
||||
aspect2.reload
|
||||
aspect2.posts.include?(status_message).should be_true
|
||||
end
|
||||
|
||||
it "should add a received post to the aspect and visible_posts array" do
|
||||
user.raw_visible_posts.include?(@status_message).should be true
|
||||
aspect.reload
|
||||
aspect.posts.include?(@status_message).should be_true
|
||||
end
|
||||
|
||||
it 'should be removed on unfriending' do
|
||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||
user.receive status_message.to_diaspora_xml, user2.person
|
||||
user.reload
|
||||
|
||||
user.raw_visible_posts.count.should == 1
|
||||
|
||||
user.unfriend(user2.person)
|
||||
|
||||
user.reload
|
||||
user.raw_visible_posts.count.should == 0
|
||||
|
||||
Post.count.should be 1
|
||||
end
|
||||
|
||||
it 'should be remove a post if the noone links to it' do
|
||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||
user.receive status_message.to_diaspora_xml, user2.person
|
||||
user.reload
|
||||
|
||||
user.raw_visible_posts.count.should == 1
|
||||
|
||||
person = user2.person
|
||||
user2.delete
|
||||
user.unfriend(person)
|
||||
|
||||
lambda {user.unfriend(person)}.should change(Post, :count).by(-1)
|
||||
user.reload
|
||||
user.raw_visible_posts.count.should == 0
|
||||
|
||||
Post.count.should be 0
|
||||
end
|
||||
|
||||
it 'should keep track of user references for one person ' do
|
||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||
user.receive status_message.to_diaspora_xml, user2.person
|
||||
user.reload
|
||||
|
||||
user.raw_visible_posts.count.should == 1
|
||||
|
||||
status_message.reload
|
||||
status_message.user_refs.should == 1
|
||||
@status_message.reload
|
||||
@status_message.user_refs.should == 1
|
||||
|
||||
user.unfriend(user2.person)
|
||||
status_message.reload
|
||||
|
||||
user.reload
|
||||
user.raw_visible_posts.count.should == 0
|
||||
|
||||
status_message.reload
|
||||
status_message.user_refs.should == 0
|
||||
|
||||
Post.count.should be 1
|
||||
@status_message.reload
|
||||
@status_message.user_refs.should == 0
|
||||
end
|
||||
|
||||
it 'should not override userrefs on receive by another person' do
|
||||
user3.activate_friend(user2.person, aspect3)
|
||||
user3.receive @status_message.to_diaspora_xml, user2.person
|
||||
|
||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||
user.receive status_message.to_diaspora_xml, user2.person
|
||||
|
||||
user3.receive status_message.to_diaspora_xml, user2.person
|
||||
user.reload
|
||||
user3.reload
|
||||
|
||||
user.raw_visible_posts.count.should == 1
|
||||
|
||||
status_message.reload
|
||||
status_message.user_refs.should == 2
|
||||
@status_message.reload
|
||||
@status_message.user_refs.should == 2
|
||||
|
||||
user.unfriend(user2.person)
|
||||
status_message.reload
|
||||
|
||||
user.reload
|
||||
user.raw_visible_posts.count.should == 0
|
||||
|
||||
status_message.reload
|
||||
status_message.user_refs.should == 1
|
||||
|
||||
Post.count.should be 1
|
||||
@status_message.reload
|
||||
@status_message.user_refs.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue