diff --git a/Changelog.md b/Changelog.md index d5a67dd83..bd07b6113 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Bug fixes * avoid posting empty comments. [#3836](https://github.com/diaspora/diaspora/issues/3836) +* Delegate parent_author to the target of a RelayableRetraction ## Refactor diff --git a/app/models/relayable_retraction.rb b/app/models/relayable_retraction.rb index a055b5eb9..4dacde55c 100644 --- a/app/models/relayable_retraction.rb +++ b/app/models/relayable_retraction.rb @@ -8,6 +8,8 @@ class RelayableRetraction < SignedRetraction attr_accessor :parent_author_signature + delegate :parent, :parent_author, to: :target, allow_nil: true + def signable_accessors super - ['parent_author_signature'] end @@ -20,11 +22,6 @@ class RelayableRetraction < SignedRetraction retraction end - def parent - return nil unless self.target.present? - self.target.parent - end - def diaspora_handle self.sender_handle end diff --git a/spec/models/relayable_retraction_spec.rb b/spec/models/relayable_retraction_spec.rb index cee206266..d76fa60a4 100644 --- a/spec/models/relayable_retraction_spec.rb +++ b/spec/models/relayable_retraction_spec.rb @@ -12,16 +12,32 @@ describe RelayableRetraction do @local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first end - describe '#subscribers' do + context "when retracting a comment" do before do @comment= @local_luke.comment!(@local_parent, "yo") @retraction= @local_luke.retract(@comment) end - it 'delegates it to target' do - arg = mock() - @retraction.target.should_receive(:subscribers).with(arg) - @retraction.subscribers(arg) + describe "#parent" do + it "delegates to to target" do + @retraction.target.should_receive(:parent) + @retraction.parent + end + end + + describe "#parent_author" do + it "delegates to target" do + @retraction.target.should_receive(:parent_author) + @retraction.parent_author + end + end + + describe '#subscribers' do + it 'delegates it to target' do + arg = mock() + @retraction.target.should_receive(:subscribers).with(arg) + @retraction.subscribers(arg) + end end end