From a0f39b4f3a8bab0f375f44a8cd3491d67ab2fb7a Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 7 May 2016 12:44:58 +0200 Subject: [PATCH] Revert "add ParentNotFound error, if parent can't be fetched" This reverts commit 5a9ba266b49f8e79415c568ccb168c03d56c0361. There is already a NotFetchable error ... --- lib/diaspora_federation/entities/relayable.rb | 5 ----- .../entities/relayable_spec.rb | 17 ++--------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/diaspora_federation/entities/relayable.rb b/lib/diaspora_federation/entities/relayable.rb index 4687ed3..4967380 100644 --- a/lib/diaspora_federation/entities/relayable.rb +++ b/lib/diaspora_federation/entities/relayable.rb @@ -216,7 +216,6 @@ module DiasporaFederation # fetch and receive parent from remote, if not available locally Federation::Fetcher.fetch_public(data[:author], type, guid) data[:parent] = DiasporaFederation.callbacks.trigger(:fetch_related_entity, type, guid) - raise ParentNotFound unless data[:parent] end end end @@ -232,10 +231,6 @@ module DiasporaFederation # Raised, if verify_signatures fails to verify signatures (signatures are wrong) class SignatureVerificationFailed < RuntimeError end - - # Raised, if parent was not found and can't be fetched - class ParentNotFound < RuntimeError - end end end end diff --git a/spec/lib/diaspora_federation/entities/relayable_spec.rb b/spec/lib/diaspora_federation/entities/relayable_spec.rb index 8a3586b..730982c 100644 --- a/spec/lib/diaspora_federation/entities/relayable_spec.rb +++ b/spec/lib/diaspora_federation/entities/relayable_spec.rb @@ -297,6 +297,8 @@ XML context "fetch parent" do before do + expect_callback(:fetch_public_key, author).and_return(author_pkey.public_key) + expect_callback(:fetch_public_key, remote_parent.author).and_return(parent_pkey.public_key) expect_callback(:fetch_private_key, author).and_return(author_pkey) expect_callback(:fetch_private_key, remote_parent.author).and_return(parent_pkey) end @@ -304,9 +306,6 @@ XML let(:xml) { SomeRelayable.new(hash).to_xml } it "fetches the parent from the backend" do - expect_callback(:fetch_public_key, author).and_return(author_pkey.public_key) - expect_callback(:fetch_public_key, remote_parent.author).and_return(parent_pkey.public_key) - expect_callback(:fetch_related_entity, "Parent", parent_guid).and_return(remote_parent) expect(Federation::Fetcher).not_to receive(:fetch_public) @@ -316,9 +315,6 @@ XML end it "fetches the parent from remote if not found on backend" do - expect_callback(:fetch_public_key, author).and_return(author_pkey.public_key) - expect_callback(:fetch_public_key, remote_parent.author).and_return(parent_pkey.public_key) - expect_callback(:fetch_related_entity, "Parent", parent_guid).and_return(nil, remote_parent) expect(Federation::Fetcher).to receive(:fetch_public).with(author, "Parent", parent_guid) @@ -326,15 +322,6 @@ XML expect(entity.parent).to eq(remote_parent) end - - it "raises if the parent can't be fetched from remote" do - expect_callback(:fetch_related_entity, "Parent", parent_guid).exactly(2).times.and_return(nil) - expect(Federation::Fetcher).to receive(:fetch_public).with(author, "Parent", parent_guid) - - expect { - SomeRelayable.from_xml(xml) - }.to raise_error DiasporaFederation::Entities::Relayable::ParentNotFound - end end describe "#sender_valid?" do