diff --git a/Changelog.md b/Changelog.md index ddf5e529572d2c41b90e91555bc1a16a847882e7..2d7e6f59a03f924197646fb2f6e710ed87b46f20 100644 --- a/Changelog.md +++ b/Changelog.md @@ -30,6 +30,10 @@ * Fix javascripts error in invitations facebox. [#3638](https://github.com/diaspora/diaspora/pull/3638) * Fix css overflow problem in aspect dropdown on welcome page. [#3637](https://github.com/diaspora/diaspora/pull/3637) +# 0.0.1.2 + +Fix exception when the root of a reshare of a reshare got deleted [#3546](https://github.com/diaspora/diaspora/issues/3546) + # 0.0.1.1 * Fix syntax error in French Javascript pluralization rule. diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index a5619a0d40a56221652baeb42192301e4dfd8559..a0558bc4efb3b7f66c96486a71b0171b4eab28d7 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -63,7 +63,7 @@ class PostPresenter end def root - PostPresenter.new(@post.absolute_root, current_user).as_json if @post.respond_to?(:root) && @post.root.present? + PostPresenter.new(@post.absolute_root, current_user).as_json if @post.respond_to?(:absolute_root) && @post.absolute_root.present? end def user_like diff --git a/spec/presenters/post_presenter_spec.rb b/spec/presenters/post_presenter_spec.rb index f23b848f6b7074f3372af0ba29ca6889c7ac426f..1d70df86f84f2176ed6764579a4c9575acc88422 100644 --- a/spec/presenters/post_presenter_spec.rb +++ b/spec/presenters/post_presenter_spec.rb @@ -44,6 +44,16 @@ describe PostPresenter do end describe '#root' do + it 'does not raise if the absolute_root does not exists' do + first_reshare = FactoryGirl.create :reshare + first_reshare.root = nil + reshare = FactoryGirl.create :reshare, :root => first_reshare + + expect { + PostPresenter.new(reshare).root + }.to_not raise_error + end + it 'does not raise if the root does not exists' do reshare = FactoryGirl.create:reshare reshare.root = nil