fix root_diaspora_id when root was deleted
This commit is contained in:
parent
ceec5084af
commit
267a1df3c4
2 changed files with 14 additions and 1 deletions
|
|
@ -26,7 +26,7 @@ class Reshare < Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_diaspora_id
|
def root_diaspora_id
|
||||||
self.root.author.diaspora_handle
|
root.try(:author).try(:diaspora_handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
delegate :o_embed_cache, :open_graph_cache,
|
delegate :o_embed_cache, :open_graph_cache,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,19 @@ describe Reshare, :type => :model do
|
||||||
expect(FactoryGirl.create(:reshare, :public => false).public).to be true
|
expect(FactoryGirl.create(:reshare, :public => false).public).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#root_diaspora_id" do
|
||||||
|
it "should return the root diaspora id" do
|
||||||
|
reshare = FactoryGirl.create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true))
|
||||||
|
expect(reshare.root_diaspora_id).to eq(bob.person.diaspora_handle)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be nil if no root found" do
|
||||||
|
reshare = FactoryGirl.create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true))
|
||||||
|
reshare.root = nil
|
||||||
|
expect(reshare.root_diaspora_id).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#receive" do
|
describe "#receive" do
|
||||||
let(:receive_reshare) { @reshare.receive(@root.author.owner, @reshare.author) }
|
let(:receive_reshare) { @reshare.receive(@root.author.owner, @reshare.author) }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue