50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
# licensed under the Affero General Public License version 3 or later. See
|
|
# the COPYRIGHT file.
|
|
|
|
require 'spec_helper'
|
|
|
|
describe Post do
|
|
before do
|
|
@user = Factory(:user)
|
|
@aspect = @user.aspects.create(:name => "winners")
|
|
end
|
|
|
|
describe 'deletion' do
|
|
it 'should delete a posts comments on delete' do
|
|
post = Factory.create(:status_message, :person => @user.person)
|
|
@user.comment "hey", :on => post
|
|
post.destroy
|
|
Post.where(:id => post.id).empty?.should == true
|
|
Comment.where(:text => "hey").empty?.should == true
|
|
end
|
|
end
|
|
|
|
describe 'serialization' do
|
|
it 'should serialize the handle and not the sender' do
|
|
post = @user.post :status_message, :message => "hello", :to => @aspect.id
|
|
xml = post.to_diaspora_xml
|
|
|
|
xml.include?(@user.person.id.to_s).should be false
|
|
xml.include?(@user.person.diaspora_handle).should be true
|
|
end
|
|
end
|
|
|
|
describe '#mutable?' do
|
|
it 'should be false by default' do
|
|
post = @user.post :status_message, :message => "hello", :to => @aspect.id
|
|
post.mutable?.should == false
|
|
end
|
|
end
|
|
|
|
describe '#decrement_user_refs' do
|
|
before do
|
|
@post = @user.post :status_message, :message => "hello", :to => @aspect.id
|
|
end
|
|
it 'decrements user_refs' do
|
|
lambda {
|
|
@post.decrement_user_refs
|
|
}.should change(@post, :user_refs).by(-1)
|
|
end
|
|
end
|
|
end
|