diaspora/spec/models/reshare_spec.rb
2011-07-21 18:22:17 -07:00

36 lines
945 B
Ruby

require 'spec_helper'
describe Reshare do
it 'has a valid Factory' do
Factory(:reshare).should be_valid
end
it 'requires root' do
reshare = Factory.build(:reshare, :root => nil)
reshare.should_not be_valid
end
it 'require public root' do
Factory.build(:reshare, :root => Factory.build(:status_message, :public => false)).should_not be_valid
end
it 'forces public' do
Factory(:reshare, :public => false).public.should be_true
end
describe "#receive" do
before do
@reshare = Factory.create(:reshare, :root => Factory(:status_message, :author => bob.person, :public => true))
@root = @reshare.root
@reshare.receive(@root.author.owner, @reshare.author)
end
it 'increments the reshare count' do
@root.resharers.count.should == 1
end
it 'adds the resharer to the re-sharers of the post' do
@root.resharers.should include(@reshare.author)
end
end
end