Refactor relayable specs and add one for retracting the object. Is pending - not complete yet.
This commit is contained in:
parent
085d6552b3
commit
5c393e9e4f
2 changed files with 32 additions and 19 deletions
|
|
@ -28,6 +28,7 @@ module Diaspora
|
|||
|
||||
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')
|
||||
#post_author.owner.retract(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,21 +9,32 @@ describe Diaspora::Relayable do
|
|||
|
||||
describe 'validations' 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)
|
||||
relayable = build_object
|
||||
relayable.should_not be_valid
|
||||
relayable.should have(1).error_on(:author_id)
|
||||
@relayable = build_object
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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 = build_object
|
||||
relayable.parent = nil
|
||||
expect { relayable.valid? }.to_not raise_exception
|
||||
@relayable.parent = nil
|
||||
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.save!
|
||||
bob.blocks.create(:person => alice.person)
|
||||
|
|
@ -31,6 +42,7 @@ describe Diaspora::Relayable do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'encryption' do
|
||||
describe '#parent_author_signature' do
|
||||
|
|
@ -62,9 +74,9 @@ describe Diaspora::Relayable do
|
|||
context 'propagation' do
|
||||
describe '#receive' 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)
|
||||
}.should_not change(@dup_object_by_parent_author.class, :count)
|
||||
}.to_not change { @dup_object_by_parent_author.class.count }
|
||||
end
|
||||
|
||||
it 'does not process if post_creator_signature is invalid' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue