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)
|
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
|
||||||
|
|
|
||||||
|
|
@ -9,25 +9,37 @@ 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
|
||||||
bob.blocks.create(:person => alice.person)
|
before do
|
||||||
relayable = build_object
|
bob.blocks.create(:person => alice.person)
|
||||||
relayable.should_not be_valid
|
@relayable = build_object
|
||||||
relayable.should have(1).error_on(:author_id)
|
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
|
||||||
|
@relayable.parent = nil
|
||||||
|
expect { @relayable.valid? }.to_not raise_exception
|
||||||
|
end
|
||||||
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
|
context "the author is added to the parent object author's ignore list later" do
|
||||||
bob.blocks.create(:person => alice.person)
|
it "is valid" do
|
||||||
relayable = build_object
|
relayable = build_object
|
||||||
relayable.parent = nil
|
relayable.save!
|
||||||
expect { relayable.valid? }.to_not raise_exception
|
bob.blocks.create(:person => alice.person)
|
||||||
end
|
relayable.should be_valid
|
||||||
|
end
|
||||||
it "is valid if the author is added to the parent post author's ignore list later" do
|
|
||||||
relayable = build_object
|
|
||||||
relayable.save!
|
|
||||||
bob.blocks.create(:person => alice.person)
|
|
||||||
relayable.should be_valid
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue