Refactor relayable specs and add one for retracting the object. Is pending - not complete yet.

This commit is contained in:
Sarah Mei 2012-02-01 19:46:31 -08:00
parent 085d6552b3
commit 5c393e9e4f
2 changed files with 32 additions and 19 deletions

View file

@ -28,6 +28,7 @@ module Diaspora
if post_author.local? && post_author.owner.ignored_people.include?(relayable_author) if post_author.local? && post_author.owner.ignored_people.include?(relayable_author)
self.errors.add(:author_id, 'This person is ignored by the post author') self.errors.add(:author_id, 'This person is ignored by the post author')
#post_author.owner.retract(self)
end end
end end
end end

View file

@ -9,21 +9,32 @@ describe Diaspora::Relayable do
describe 'validations' do describe 'validations' do
describe 'on :author_id' do describe 'on :author_id' do
it "is invalid if the author is on the parent post author's ignore list when object is created" do context "the author is on the parent object author's ignore list when object is created" do
before do
bob.blocks.create(:person => alice.person) bob.blocks.create(:person => alice.person)
relayable = build_object @relayable = build_object
relayable.should_not be_valid end
relayable.should have(1).error_on(:author_id)
it "is invalid" do
@relayable.should_not be_valid
@relayable.should have(1).error_on(:author_id)
end
it "sends a retraction for the object" do
pending 'need to figure out how to test this'
RelayableRetraction.should_receive(:build)
Postzord::Dispatcher.should_receive(:build)
@relayable.valid?
end end
it "works if the object has no parent" do # This can happen if we get a comment for a post that's been deleted it "works if the object has no parent" do # This can happen if we get a comment for a post that's been deleted
bob.blocks.create(:person => alice.person) @relayable.parent = nil
relayable = build_object expect { @relayable.valid? }.to_not raise_exception
relayable.parent = nil end
expect { relayable.valid? }.to_not raise_exception
end end
it "is valid if the author is added to the parent post author's ignore list later" do context "the author is added to the parent object author's ignore list later" do
it "is valid" do
relayable = build_object relayable = build_object
relayable.save! relayable.save!
bob.blocks.create(:person => alice.person) bob.blocks.create(:person => alice.person)
@ -31,6 +42,7 @@ describe Diaspora::Relayable do
end end
end end
end end
end
context 'encryption' do context 'encryption' do
describe '#parent_author_signature' do describe '#parent_author_signature' do
@ -62,9 +74,9 @@ describe Diaspora::Relayable do
context 'propagation' do context 'propagation' do
describe '#receive' do describe '#receive' do
it 'does not overwrite a object that is already in the db' do it 'does not overwrite a object that is already in the db' do
lambda { expect {
@dup_object_by_parent_author.receive(@local_leia, @local_luke.person) @dup_object_by_parent_author.receive(@local_leia, @local_luke.person)
}.should_not change(@dup_object_by_parent_author.class, :count) }.to_not change { @dup_object_by_parent_author.class.count }
end end
it 'does not process if post_creator_signature is invalid' do it 'does not process if post_creator_signature is invalid' do