delegate parent_author to the target of a RelayableRetraction

This commit is contained in:
Jonne Haß 2013-02-28 17:01:58 +01:00
parent df1abefc1c
commit ccedb6eff0
3 changed files with 24 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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